fix(workflows): if/while/do-while execute() fail cleanly on a non-list branch/body#3528
Open
jawwad-ali wants to merge 1 commit into
Open
fix(workflows): if/while/do-while execute() fail cleanly on a non-list branch/body#3528jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
…t branch IfThenStep passes config['then']/['else'] and WhileStep/DoWhileStep pass config['steps'] straight through as StepResult.next_steps without checking they are lists. The engine does not auto-validate step config before execute(), so an unvalidated run with a non-list branch/body (a scalar/mapping authoring mistake) passed a non-iterable as next_steps and crashed the whole run. validate() already rejects these, but execute() must fail loudly too. Add an isinstance(list) guard to each execute(), returning a FAILED StepResult with a clear message — mirroring the switch step's non-mapping 'cases' guard and the fan-out step's non-list 'items' guard. Parametrized tests on all three steps feed a str/dict/int branch and assert FAILED (fail before: the non-iterable next_steps crashed execution). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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']andWhileStep/DoWhileStep.executereturnconfig['steps']directly asStepResult.next_steps, with no check that they're lists:The engine does not auto-validate step config before
execute(), so an unvalidated run with a non-list branch/body (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 to eachexecute(), returning aFAILEDStepResultwith a clear message — mirroring the existing guards in the sibling control-flow steps (switch's non-mappingcases,fan-out's non-listitems).Test
Parametrized
test_execute_rejects_non_list_branch(if) andtest_execute_rejects_non_list_steps(while, do-while) feed astr/dict/intand assertFAILED— fail before (the non-iterablenext_stepscrashed execution), pass after.🤖 Written with the assistance of Claude Code (AI). Bug self-found; fix/tests verified locally (fail-before / pass-after), ruff clean.