fix(workflows): fail gate step loudly on a malformed 'options'#3595
Merged
mnriem merged 1 commit intoJul 21, 2026
Conversation
`GateStep.validate` rejects a non-list (or empty) `options` and requires every option to be a string, but the engine does not auto-validate before `execute`. On an unvalidated run a scalar/dict/None `options` reached `_prompt` and crashed the whole workflow with a raw `TypeError` (`enumerate`/`len` on a non-iterable) or `KeyError` (indexing a dict); an empty list spun `_prompt`'s input loop forever; a non-string option crashed the reject check at `choice.lower()` with `AttributeError`. Guard `execute` to FAIL the step cleanly instead, before the non-TTY PAUSE short-circuit so the error surfaces in CI too rather than pausing and only crashing later on interactive resume. Mirrors the switch 'cases' and command 'input' unvalidated-execute guards. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds runtime validation so malformed gate options fail cleanly instead of crashing or hanging workflows.
Changes:
- Rejects options that are not non-empty lists of strings.
- Adds interactive and non-TTY regression coverage.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/workflows/steps/gate/__init__.py |
Adds the runtime options guard. |
tests/test_workflows.py |
Tests malformed options handling. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Medium
Collaborator
|
Thank you! |
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
GateStep.validaterejects a non-list (or empty)optionsand requires every option to be a string, but the workflow engine does not auto-validate a step before callingexecute. On an unvalidated run a malformedoptionsslipped straight through to the interactive prompt and took down the whole workflow:Noneoptions→ rawTypeError(enumerate/lenon a non-iterable) orKeyError(indexing a dict) inside_prompt[]→_prompt'swhile True:input loop can never satisfy1 <= n <= 0, so it spins forever[123, 456]) → passes the shape check but crashes the reject test atchoice.lower()withAttributeErrorThis mirrors an established bug class in this repo:
validate()correctly rejects bad input, butexecute()(reachable on an unvalidated run) crashes on it instead of failing the step cleanly — same shape as the switchcases(#3481) and commandinputguards.Fix
Guard
executeto returnStepStatus.FAILEDwith a clear error whenoptionsis not a non-empty list of strings. The check runs before the non-TTYPAUSEDshort-circuit, so a misconfigured gate surfaces as FAILED in CI rather than pausing and only crashing later when an operator resumes on a real terminal.Tests
Added regression tests under
TestGateStep:test_execute_non_list_options_fails_cleanly(parametrized over5,{...},None,[],"approve")test_execute_non_string_options_element_fails_cleanlytest_execute_non_list_options_fails_in_non_tty_tooVerified test-the-test: with the source fix stashed, the scalar cases crash and the empty-list case hangs
_promptforever; with the fix all 21TestGateSteptests pass.🤖 Generated with Claude Code