diff --git a/internal/response-consumer/handler.go b/internal/response-consumer/handler.go index 177a8a65..32651a5a 100644 --- a/internal/response-consumer/handler.go +++ b/internal/response-consumer/handler.go @@ -83,6 +83,15 @@ func (this *handler) onMessage(ctx context.Context, msg *k.Message) { selectResult := baseQuery.Select("id", "status", "response_full").First(&run) + if selectResult.Error != nil { + if errors.Is(selectResult.Error, gorm.ErrRecordNotFound) { + return nil + } + + utils.GetLogFromContext(ctx).Errorw("Error fetching run from db", "error", selectResult.Error) + return selectResult.Error + } + if requestType == satMessageHeaderValue { satellite.SortSatEvents(value.SatEvents) @@ -101,15 +110,6 @@ func (this *handler) onMessage(ctx context.Context, msg *k.Message) { eventsSerialized = utils.MustMarshal(value.RunnerEvents) } - if selectResult.Error != nil { - if errors.Is(selectResult.Error, gorm.ErrRecordNotFound) { - return nil - } - - utils.GetLogFromContext(ctx).Errorw("Error fetching run from db", "error", selectResult.Error) - return selectResult.Error - } - toUpdate := db.Run{ Status: status, Events: eventsSerialized,