Skip to content

Commit

Permalink
fix: trigger result error handling (#3340)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathnogueira authored Nov 7, 2023
1 parent 540a872 commit d2abf0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 8 additions & 6 deletions server/executor/trigger_result_processor_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,17 @@ func (r triggerResultProcessorWorker) ProcessItem(ctx context.Context, job Job)
Type: "run_update",
Content: RunResult{Run: job.Run, Err: err},
})
} else {
err := r.eventEmitter.Emit(ctx, events.TriggerExecutionSuccess(job.Run.TestID, job.Run.ID))
if err != nil {
r.handleDBError(job.Run, err)
}

r.handleDBError(job.Run, r.updater.Update(ctx, job.Run))
return
}

job.Run.State = test.RunStateAwaitingTrace
err := r.eventEmitter.Emit(ctx, events.TriggerExecutionSuccess(job.Run.TestID, job.Run.ID))
if err != nil {
r.handleDBError(job.Run, err)
}

job.Run.State = test.RunStateAwaitingTrace
r.handleDBError(job.Run, r.updater.Update(ctx, job.Run))

r.outputQueue.Enqueue(ctx, job)
Expand Down
4 changes: 3 additions & 1 deletion server/test/trigger/trigger_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ type triggerResultV2 struct {
GRPC *GRPCResponse `json:"grpc,omitempty"`
TraceID *TraceIDResponse `json:"traceid,omitempty"`
Kafka *KafkaResponse `json:"kafka,omitempty"`
Error *TriggerError `json:"error,omitempty"`
}

func (tr *triggerResultV2) valid() bool {
return tr.HTTP != nil || tr.GRPC != nil || tr.TraceID != nil || tr.Kafka != nil
return tr.HTTP != nil || tr.GRPC != nil || tr.TraceID != nil || tr.Kafka != nil || tr.Error != nil
}

func (t *TriggerResult) UnmarshalJSON(data []byte) error {
Expand All @@ -136,6 +137,7 @@ func (t *TriggerResult) UnmarshalJSON(data []byte) error {
t.GRPC = v2.GRPC
t.TraceID = v2.TraceID
t.Kafka = v2.Kafka
t.Error = v2.Error

return nil
}
Expand Down

0 comments on commit d2abf0e

Please sign in to comment.