fix(workflows): require a steps body on while and do-while loops - #4149
Open
jawwad-ali wants to merge 1 commit into
Open
fix(workflows): require a steps body on while and do-while loops#4149jawwad-ali wants to merge 1 commit into
steps body on while and do-while loops#4149jawwad-ali wants to merge 1 commit into
Conversation
Both loop steps type-check `steps` ("must be a list") but never require it
to be present, so an absent body silently becomes `[]`. `if` already
requires `then`, and `fan-out` already requires both `items` and `step`.
The mistype is unusually easy here because the fan-out step's own payload
key is the singular `step:` while the loops use `steps:`. Writing `step:` on
a `while` passed `specify workflow validate` with zero errors:
A. while, body key typo'd as singular step:
validate: []
execute : StepStatus.COMPLETED | next_steps = []
B. do-while, no steps at all:
validate: []
execute : StepStatus.COMPLETED | next_steps = []
At run time the step reports COMPLETED while returning no `next_steps`, so
the engine's `if result.next_steps:` block never fires and the loop the
workflow is built around never runs even once. `DoWhileStep`'s own docstring
promises "The first invocation always returns the nested steps for
execution".
Co-Authored-By: Claude Opus 5 (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.
Problem
Both loop steps type-check
steps('steps' must be a list) but never require it to be present, so an absent body silently becomes[].Every sibling control-flow step already requires its body:
ifthenif_then/__init__.py:84fan-outitems+stepfan_out/__init__.py:87, 92whilestepsdo-whilestepsThe mistype is unusually easy here: the fan-out step's own payload key is the singular
step:while the loops usesteps:.Reproduction on current
mainspecify workflow validatereports zero errors. At run time the step reports COMPLETED while returning nonext_steps, so the engine'sif result.next_steps:block never fires and the retry loop the workflow is built around never runs even once — a silent no-op with no diagnostic anywhere.For
do-whilethis also contradicts the step's own docstring: "The first invocation always returns the nested steps for execution."Fix
Add the missing presence check to both
validate()methods, worded to match the existingifstep's message.Behaviour change — disclosed
A workflow that today declares a
while/do-whilewith nostepskey now failsspecify workflow validateinstead of passing. That is the point of the fix: such a loop is already a guaranteed no-op, so the change converts a silent misconfiguration into a clear error rather than altering any working behaviour. Runtime execution is untouched.I scanned every workflow-shaped YAML in the repo — 0 bodyless loops, so no in-tree workflow or template is affected. An explicitly empty
steps: []still validates exactly as before.Verification
upstream/main, the 2 new tests fail → 37 passed with the fix.tests/test_workflows.py+tests/workflows,-k "While or DoWhile or Loop or loop or Validat or validate or Engine"): 283 passed.test_validate_missing_fieldstests already pass"steps": [], so they are unaffected.uvx ruff@0.15.0 check src tests→ cleanWritten with assistance from Claude Code. Bug found, reproduced, and verified by me on current
main.