fix(workflows): reject non-list input 'enum' instead of crashing#3552
Open
Noor-ul-ain001 wants to merge 1 commit into
Open
fix(workflows): reject non-list input 'enum' instead of crashing#3552Noor-ul-ain001 wants to merge 1 commit into
Noor-ul-ain001 wants to merge 1 commit into
Conversation
A workflow input `enum` was never type-checked, so a scalar value
(`enum: 5`, `enum: true`) made the `value not in enum_values`
membership test raise a raw `TypeError` ("argument of type 'int' is not
... iterable"). This escaped `validate_workflow`'s `except ValueError`,
breaking its documented "return errors, never raise" contract, and
crashed `_resolve_inputs` outright at run time (`execute` does not
auto-validate the definition first). A bare-string `enum` was silently
worse: `value in "abc"` is a substring/character test, not enum
membership.
Require `enum` to be a list in both `_coerce_input` (the single runtime
choke point) and the authoring-time inputs loop (so a bad `enum` on an
input with no `default`, or the `integration: auto` case that strips
`enum` before coercion, is still caught). Suppress the redundant
"invalid default" report when `enum` is already flagged, so the operator
sees one clear error.
Same unvalidated-config crash class as the switch/fan-in/fan-out
non-list guards.
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
A workflow input
enumis never type-checked. A scalar value crashes the validator and the runtime input resolver with a rawTypeErrorinstead of producing a clean error:The crash comes from the
value not in enum_valuesmembership test inWorkflowEngine._coerce_input. Two paths are affected:validate_workflow()documents a "return errors, never raise" contract, but theTypeErrorescapes itsexcept ValueErrorand propagates.execute()does not auto-validate the definition (seeload_workflow's docstring), so_resolve_inputshits the same crash when a provided value is coerced.A bare-string
enum(enum: "abc") is silently worse:value in "abc"becomes a substring/character test rather than enum membership, so it passes validation while doing the wrong thing at runtime.Fix
Require
enumto be a list in both places:_coerce_input(the single runtime choke point) raises a cleanValueErroron a non-listenum.validate_workflowreports it as a validation error — needed independently because_coerce_inputis only reached from validation when adefaultis present, and theintegration: autocase stripsenumbefore coercing.The redundant "invalid default" report is suppressed when
enumis already flagged, so the operator sees one clear error rather than the same problem re-framed twice.This is the same unvalidated-config crash class as the existing switch / fan-in / fan-out non-list guards.
Tests
Added to
tests/test_workflows.py:enum(no default) → clean validation error, no crashenum→ rejected + reported exactly once (no duplicate)enumat run time via_resolve_inputs→ cleanValueError, notTypeErrorenum→ still validates and still checks the default against membershipFull
test_workflows.pypasses except the pre-existing Windows-without-elevation symlink-guard tests (unrelated to this change).🤖 Generated with Claude Code