fix(workflows): engine loop cap ignores bool max_iterations#3270
Open
jawwad-ali wants to merge 1 commit into
Open
fix(workflows): engine loop cap ignores bool max_iterations#3270jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
The while/do-while loop cap guard 'not isinstance(max_iters, int) or max_iters < 1' does not fall back to the default for a boolean max_iterations: isinstance(True, int) is True and True < 1 is False. The loop then runs range(max_iters - 1) == range(True - 1) == range(0), capping at a single iteration instead of the default 10. Exclude bools, mirroring the merged while/do-while validators (github#3237) and this function's own continue_on_error bool handling. execute() does not auto-validate, so this engine guard is the only defence. Co-Authored-By: Claude Opus 4.8 <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.
Description
The workflow engine's while/do-while loop-cap guard:
does not fall back to the default for a boolean
max_iterations. Sinceisinstance(True, int)isTrueandTrue < 1isFalse, amax_iterations: trueslips past the guard and the loop runsrange(True - 1) == range(0)— capping at a single iteration instead of the default 10.This is the same bool-is-int trap already fixed in the
while/do-whilevalidators (#3237); the engine's runtime path had the same gap, andWorkflowEngine.execute()does not auto-validate, so this guard is the only line of defence at run time. The function's siblingcontinue_on_error is Truehandling already special-cases bools.Fix
Testing
test_loop_with_bool_max_iterations_uses_default_cap: an unvalidatedfrom_stringworkflow withmax_iterations: trueand a condition that stays truthy; asserts the tick counter reaches 10 (default cap). Fails before ('1' == '10'— capped at one iteration, verified by source-stash), passes after.uvx ruff checkclean; the existingtest_while_loop_runs_to_max_when_condition_stays_true(int max_iterations) stays green.AI Disclosure
Found and fixed with Claude Code (Claude Opus 4.8) under my direction. AI flagged the runtime gap left by the validator-only #3237 fix; I confirmed the single-iteration cap, proved fail-before via source-stash, and reviewed the diff before submitting.