diff --git a/module/pipeline_event_recording_test.go b/module/pipeline_event_recording_test.go index 2bf35a79..216628b4 100644 --- a/module/pipeline_event_recording_test.go +++ b/module/pipeline_event_recording_test.go @@ -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{} diff --git a/module/pipeline_executor.go b/module/pipeline_executor.go index 1c9fa4ed..368c8363 100644 --- a/module/pipeline_executor.go +++ b/module/pipeline_executor.go @@ -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 }