storage: Avoid panic when no previous versions in history (#88880)

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
This commit is contained in:
Dave Henderson 2024-06-06 21:33:08 -04:00 committed by GitHub
parent 003e3efce9
commit c931a44503
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1095,6 +1095,11 @@ func (s *sqlEntityServer) poll(since int64, out chan *entity.EntityWatchResponse
return err return err
} }
if len(history.Versions) == 0 {
ctxLogger.Error("error reading previous entity", "guid", updated.Guid, "err", "no previous version found")
return errors.New("no previous version found")
}
result.Previous = history.Versions[0] result.Previous = history.Versions[0]
} }