fix(workflows): reject non-string 'condition' in if/while/do-while steps#3706
Open
jawwad-ali wants to merge 1 commit into
Open
fix(workflows): reject non-string 'condition' in if/while/do-while steps#3706jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
`if_then`, `while_loop`, and `do_while` validate() confirm `condition` is
present but never that it is a string. execute() feeds it to
`evaluate_condition()`, which returns a non-string as-is and takes `bool()`
of it -- so `condition: [1, 2]` (a list authoring mistake) silently resolves
to `True`, branching wrongly / spinning the loop to `max_iterations`, with no
error reported.
Reject a present-but-non-string `condition` at validation, mirroring the
existing prompt/shell/command 'must be a string' guards. `"true"`/`"false"`
and expressions like `"{{ ... }}"` are strings, so they stay valid.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
Problem
IfThenStep,WhileStep, andDoWhileStepvalidate()confirm thatconditionis present but never that it is a string.At run time
execute()feedsconditiontoevaluate_condition():So a non-string condition is returned unchanged and
bool()-coerced. A list/dict/number authoring mistake silently resolves to a truthiness instead of erroring:condition: [1, 2]→bool([1, 2])→ always True → if-branch always taken / while-loop spins tomax_iterations.condition: {}→ always False, etc.No error is reported, so the mistake is invisible.
Fix
Reject a present-but-non-string
conditionin each of the three steps'validate(), mirroring the existingprompt/shell/command'must be a string' guards."true"/"false"and expressions like"{{ inputs.flag }}"are strings, so they remain valid — no behaviour change for correct workflows.Verification
[list, dict, int, bool]) across all three step classes: fail before the guard (12 failures — the non-string conditions pass validation), pass after.test_validate_accepts_string_conditionconfirms"true"/"false"/"{{ ... }}"still validate.TestIfThenStep/TestWhileStep/TestDoWhileStep: 53 passed.ruff checkclean on all changed files.AI-assisted: authored with Claude Code. I traced the runtime path (
evaluate_condition→bool()), confirmed the silent-coercion onmain, and verified the guards fail-before/pass-after.