fix(workflows): if step execute() fails cleanly on a non-list branch#3528
Open
jawwad-ali wants to merge 1 commit into
Open
fix(workflows): if step execute() fails cleanly on a non-list branch#3528jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
IfThenStep.execute returns config['then']/['else'] directly as StepResult.next_steps with no check that it is a list. The engine does not auto-validate step config before execute(), so an unvalidated run with a non-list branch (a scalar or mapping authoring mistake) passes a non-iterable as next_steps and crashes the whole run. validate() catches this, but execute() should fail the step loudly instead. Add an isinstance(list) guard returning a FAILED StepResult, completing the same guard github#3519 added to the while/do-while steps (and that its comment already references for the 'if' step) and mirroring the switch step's 'cases' guard. Parametrized test feeds a str/dict/int branch and asserts FAILED (fails before: the non-iterable next_steps crashed execution). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9ef71fa to
c89db54
Compare
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
IfThenStep.executereturnsconfig['then']/['else']directly asStepResult.next_stepswith no check that it's a list:The engine does not auto-validate step config before
execute(), so an unvalidated run with a non-list branch (a scalar or mapping authoring mistake) passes a non-iterable asnext_stepsand crashes the whole run.validate()catches this, butexecute()should fail the step loudly rather than take down the run.Fix
Add an
isinstance(..., list)guard returning aFAILEDStepResult. This completes the same guard #3519 added to thewhile/do-whilesteps — whose comment already references theifstep as a peer — and mirrors theswitchstep'scasesguard.Test
Parametrized
test_execute_rejects_non_list_branchfeeds astr/dict/intbranch and assertsFAILED— fails before (the non-iterablenext_stepscrashed execution), passes after.🤖 Written with the assistance of Claude Code (AI). Bug self-found; fix/tests verified locally (fail-before / pass-after), ruff clean.