diff --git a/internal/domain/workflow/workflow_call.go b/internal/domain/workflow/workflow_call.go index f2297a138..bc68ec9ea 100644 --- a/internal/domain/workflow/workflow_call.go +++ b/internal/domain/workflow/workflow_call.go @@ -139,13 +139,7 @@ func runWorkflowCall(ctx context.Context, s workflowCallSettings, tc *TaskContex return fmt.Errorf("%s: could not be recorded: %w", WorkflowCallStepName, err) } if !s.Wait { - // The call step closes at once: the callee runs on, and nothing the - // caller waits on remains open. - if err := tc.finishChildStep(ctx, callStep, taskstate.StepSucceeded, - fmt.Sprintf("started %q (task %d); no wait", s.Workflow, callee.ID), 0); err != nil { - return fmt.Errorf("%s: could not be closed: %w", WorkflowCallStepName, err) - } - return nil + return tc.closeUnwaitedCall(ctx, s, callStep, callee.ID) } // Close the call step with the callee's outcome, unless the caller itself was // cancelled. @@ -176,6 +170,16 @@ func runWorkflowCall(ctx context.Context, s workflowCallSettings, tc *TaskContex return nil } +// closeUnwaitedCall closes the call step of a wait:false call at once: the +// callee runs on, and nothing the caller waits on remains open. +func (tc *TaskContext) closeUnwaitedCall(ctx context.Context, s workflowCallSettings, callStep, calleeTaskID int64) error { + if err := tc.finishChildStep(ctx, callStep, taskstate.StepSucceeded, + fmt.Sprintf("started %q (task %d); no wait", s.Workflow, calleeTaskID), 0); err != nil { + return fmt.Errorf("%s: could not be closed: %w", WorkflowCallStepName, err) + } + return nil +} + // workflowCallPath is the running call site's declared path within the run, // which names the step and identifies the call. Every registry stage is // wrapped, so a run reaching here without a path has no identity to key its diff --git a/internal/domain/workflow/workflow_call_test.go b/internal/domain/workflow/workflow_call_test.go index 2438e680d..8e063c892 100644 --- a/internal/domain/workflow/workflow_call_test.go +++ b/internal/domain/workflow/workflow_call_test.go @@ -120,7 +120,9 @@ steps: - type: workflow.call settings: {workflow: callee} `, - wantErr: "needs an id", + // The whole message, so the refusal still names the step it + // refused: this is where a pinned definition is compiled. + wantErr: `workflow "caller" step 1: "workflow.call" needs an id`, }, } for _, tt := range tests { @@ -260,22 +262,6 @@ steps: }, wantErr: `workflow "caller" step 1 branch "a" step 1 calls "missing", which is not defined`, }, - { - name: "a call step with no id is refused naming the step", - defs: map[string]string{ - "caller": `id: caller -repository: none -steps: - - {type: workflow.call, settings: {workflow: callee}} -`, - "callee": `id: callee -repository: none -steps: - - type: workflow.finish -`, - }, - wantErr: `workflow "caller" step 1: "workflow.call" needs an id`, - }, { name: "a cycle through branch calls is refused", defs: map[string]string{ diff --git a/internal/infrastructure/postgres/store.go b/internal/infrastructure/postgres/store.go index aa287d868..c7a4f4596 100644 --- a/internal/infrastructure/postgres/store.go +++ b/internal/infrastructure/postgres/store.go @@ -786,7 +786,7 @@ func (s *Store) TaskByID(ctx context.Context, taskID int64) (*workflow.Task, err // callerTaskID and callKey when there is one. A child that ended dead or // declined freed its key, so such a call starts a fresh child. The caller must // be running and within workflow.MaxCallDepth. -func (s *Store) StartCall(ctx context.Context, callerTaskID int64, callKey string, wf string, inputs map[string]any) (*workflow.Task, error) { +func (s *Store) StartCall(ctx context.Context, callerTaskID int64, callKey, wf string, inputs map[string]any) (*workflow.Task, error) { encoded, err := task.EncodeInputs(inputs) if err != nil { return nil, err