refactor(workflow): keep the call key change inside the lint gate

golangci-lint failed on the change and had not before: gofumpt wants
StartCall's same-typed parameters grouped, and runWorkflowCall reached a
cyclomatic complexity of 16. The unwaited call's early close moves into
closeUnwaitedCall on *TaskContext -- it needs only the call step, the
callee and the settings -- which leaves runWorkflowCall below the limit
with its behaviour unchanged.

The walk's id-less call case is deleted: ParseDefinition now refuses that
definition before validateWorkflowCalls runs, so it passed for the wrong
reason. The refusal is pinned where it happens instead, by the compile
case in TestWorkflowCallKeyIsTheDeclaredPath, now asserting the whole
message so it still names the step it refused.
This commit is contained in:
sam committed 2026-10-08 22:31:07 +11:00
1 parent 3c99f69fee
commit aae01431b4
3 files changed
+15 -25

No files matched your search

+11 -7
View File
@@ -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
+3 -17
View File
@@ -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{
+1 -1
View File
@@ -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