fix(workflows): reject a retry gate whose verdict enum forbids the reset value - #3912
Merged
Merged
Conversation
…set value
A gate with `on_reject: retry` consumes a bound reject verdict before
pausing by resetting the named input to `""` (documented behaviour, so a
later resume prompts again). Every `resume()` re-resolves the persisted
inputs through `_coerce_input`.
Those two rules collide when the bound input declares an `enum` that does
not list `""`. The reset writes a value the input's own enum forbids, and
the run wedges:
inputs:
spec_verdict:
type: string
enum: [approve, reject]
steps:
- id: review
type: gate
options: [approve, reject]
on_reject: retry
verdict_input: spec_verdict
$ specify workflow run wf --input spec_verdict=reject
Status: paused
$ specify workflow resume <run_id> --input note=b
Error: Input 'spec_verdict' value '' not in allowed values:
['approve', 'reject'].
The workflow validates clean and the first run looks fine, so the failure
only appears at the second resume. It is also unrecoverable in practice:
`_resolve_inputs` re-coerces the whole persisted map, so *any* resume that
supplies an input dies on the stored `""`. Only a resume with no inputs at
all still works -- and that is precisely the call that cannot deliver a new
verdict, which is the one thing the retry cycle exists to allow.
Extend the existing `verdict_input` cross-check (which already confirms the
name is declared) to also require that a retry-bound input's `enum` admits
the reset sentinel, and report it with a fix hint. To do that, thread the
input *definitions* through `_validate_steps` instead of just their names.
Rejected the alternative of popping the key instead of writing `""`: that
lets the input's `default` flow back in on the next resume, so a gate the
user just rejected would silently auto-approve.
Docs: note the `enum` requirement next to the reset behaviour it follows
from.
Adds 4 validation tests for the new guard plus a characterization test that
drives the engine directly to pin the wedge it prevents.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Assisted-by: Claude Opus 5 (1M context)
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents retry gates from persisting an empty verdict that violates the bound input’s enum.
Changes:
- Validates retry-gate verdict enums include
"". - Adds validation and regression tests.
- Documents the empty-string requirement.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/workflows/engine.py |
Adds the enum cross-check. |
tests/test_workflows.py |
Covers valid, invalid, and wedged scenarios. |
docs/reference/workflows.md |
Documents retry reset requirements. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Balanced
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.
Problem
A gate with
on_reject: retryconsumes a bound reject verdict before pausing by resetting the named input to""— documented behaviour, so a later resume prompts again. Everyresume()re-resolves the persisted inputs through_coerce_input.Those two rules collide when the bound input declares an
enumthat does not list"". The reset writes a value the input's own enum forbids, and the run wedges:The workflow validates clean and the first run looks fine, so the failure only appears at the second resume. It is also unrecoverable in practice:
_resolve_inputsre-coerces the whole persisted map, so any resume that supplies an input dies on the stored"". Only a resume with no inputs at all still works — and that is precisely the call that cannot deliver a new verdict, which is the one thing the retry cycle exists to allow.Fix
Extend the existing
verdict_inputcross-check (which already confirms the name is declared) to also require that a retry-bound input'senumadmits the reset sentinel, and report it with a fix hint. To do that, thread the input definitions through_validate_stepsinstead of just their names.Rejected the alternative of popping the key instead of writing
"": that lets the input'sdefaultflow back in on the next resume, so a gate the user just rejected would silently auto-approve.Docs: note the
enumrequirement next to the reset behaviour it follows from.Tests
4 validation tests for the new guard (rejects a retry gate whose enum omits
""; passes when the enum includes it, whenon_rejectisabort/skip, and when there is no enum at all), plus a characterization test that drives the engine directly to pin the wedge the guard prevents.Verified the guard test fails without the engine change. Full
tests/test_workflows.py: 870 passed, 20 failed — the same 20 symlink tests fail identically on an unmodifiedupstream/maincheckout (they need symlink privileges this Windows box lacks), so no regressions.🤖 Generated with Claude Code