fix(workflows): reject bool max_iterations in engine re-eval guard#3470
Open
Noor-ul-ain001 wants to merge 1 commit into
Open
fix(workflows): reject bool max_iterations in engine re-eval guard#3470Noor-ul-ain001 wants to merge 1 commit into
Noor-ul-ain001 wants to merge 1 commit into
Conversation
The While/DoWhile step validators already reject `max_iterations: true` as a type error (bool is an int subclass, so it would otherwise pass the `isinstance(..., int)` check and, since `True - 1 == 0`, silently cap the loop at a single iteration). The engine's re-evaluation guard used the older `not isinstance(max_iters, int) or max_iters < 1` shape, so on an unvalidated run a boolean slipped through and ran the loop body just once instead of falling back to the safe default of 10. Add the explicit `isinstance(max_iters, bool)` rejection so the engine guard matches the step validators and an unvalidated run degrades to the default rather than silently under-running the loop. 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.
Summary
The
while/do-whilestep validators already rejectmax_iterations: trueas a type error —boolis a subclass ofint, so a boolean passes a bareisinstance(..., int)check, and sinceTrue - 1 == 0it would silently cap the loop at a single iteration (0 re-iterations).The engine's re-evaluation guard in
WorkflowEngine, however, still used the older shape:On an unvalidated run (executing a definition without first calling the validators), a boolean
max_iterationsslipped through this guard and ran the loop body just once instead of falling back to the safe default of 10.Fix
Add the explicit
isinstance(max_iters, bool)rejection so the engine guard matchesWhileStep.validate()/DoWhileStep.validate(). An unvalidated run now degrades to the default of 10 rather than silently under-running the loop.Testing
test_while_loop_bool_max_iterations_falls_back_to_default, which runs awhilestep withmax_iterations: truethrough the engine and asserts the body executes 10 times (not 1).git stash).🤖 Generated with Claude Code