Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions module/pipeline_event_recording_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,30 @@ func TestPipeline_NilEventRecorder_NoEvents(t *testing.T) {
}
}

func TestPipeline_EventRecorder_EmptyExecutionIDSkipsRecording(t *testing.T) {
recorder := &mockEventRecorder{
err: fmt.Errorf("parse execution ID \"\": invalid UUID length: 0"),
}

p := &Pipeline{
Name: "inline-http",
Steps: []PipelineStep{newMockStep("step1", map[string]any{"ok": true})},
OnError: ErrorStrategyStop,
EventRecorder: recorder,
}

pc, err := p.Execute(context.Background(), nil)
if err != nil {
t.Fatalf("pipeline should succeed without execution tracking: %v", err)
}
if pc.Current["ok"] != true {
t.Fatalf("expected step output to be merged, got %#v", pc.Current)
}
if events := recorder.getEvents(); len(events) != 0 {
t.Fatalf("empty ExecutionID should skip recorder calls, got %+v", events)
}
}

func TestPipeline_EventRecorder_SuccessfulExecution(t *testing.T) {
recorder := &mockEventRecorder{}

Expand Down
7 changes: 4 additions & 3 deletions module/pipeline_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ type Pipeline struct {
}

// recordEvent is a nil-safe helper that records an event via EventRecorder.
// If EventRecorder is nil, this is a no-op. Errors are logged but never
// returned — event recording is best-effort and must not fail the pipeline.
// If EventRecorder is nil or ExecutionID is empty, this is a no-op. Errors are
// logged but never returned — event recording is best-effort and must not fail
// the pipeline.
func (p *Pipeline) recordEvent(ctx context.Context, eventType string, data map[string]any) {
if p.EventRecorder == nil {
if p.EventRecorder == nil || p.ExecutionID == "" {
return
}

Expand Down
Loading