fix(console): fail fast in select_with_arrows when stdin is not a TTY - #4155
Open
yunaremaia wants to merge 1 commit into
Open
fix(console): fail fast in select_with_arrows when stdin is not a TTY#4155yunaremaia wants to merge 1 commit into
yunaremaia wants to merge 1 commit into
Conversation
…github#4152) specify init can hang indefinitely at arrow-key selection prompts (select_with_arrows) when stdin is not attached to a TTY — agent harnesses, CI, or piped input wait on readkey() forever with no timeout, no error, and no output. select_with_arrows now detects non-interactive stdin and: - resolves to default_key immediately when one is provided (making a fully scripted init expressible), or - raises ValueError naming the missing interactive session when no default exists, instead of blocking forever. Both call sites in init.py already guard with _stdin_is_interactive(), so this is defense in depth: any future caller of the selector cannot hang a non-interactive process again. 3 new tests: no-TTY without default raises, no-TTY with default resolves, TTY path still interactive. 8/8 console tests green; no regressions (test_cli failures are pre-existing in this environment, identical count with and without this change). Signed-off-by: Yunare Maia <yunare@gmail.com>
Author
|
Hi maintainers — the workflow runs on this PR show
Could you approve the runs when you get a chance? Thanks! |
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.
Fixes #4152
Problem
specify initcan hang indefinitely at arrow-key selection prompts when stdin is not attached to a TTY (agent harness, CI, piped input).select_with_arrowsblocks inreadkey()waiting for keypresses that never arrive — no timeout, no error, no output. This matters because agent-driven workflows are precisely the environments with no TTY, and Spec Kit is a natural fit for them.Fix (defense in depth)
select_with_arrowsnow detects non-interactive stdin (sys.stdin.isatty()) and:default_keyimmediately when one is provided — making a fully scripted init expressible without needing a flag for every prompt (issue option 2).ValueErrornaming the missing interactive session when no default exists — fail fast with an actionable message instead of hanging (issue option 1).Both call sites in
init.pyalready guard with_stdin_is_interactive(), so this change cannot alter existing behavior for guarded paths — it closes the hang for any future or unguarded caller of the selector (issue: "there is no flag that reaches every prompt").Tests
New file
tests/test_console_non_interactive.py(3 tests):ValueError("not a terminal")Verified:
8/8console tests green.tests/integrations/test_cli.pyfailures are pre-existing in this environment (84 failures with and without this change — identical count), so no regressions introduced.