fix(prompt): fail fast when stdin is not a terminal - #280
Open
stantheman0128 wants to merge 1 commit into
Open
stantheman0128 wants to merge 1 commit into
stantheman0128 wants to merge 1 commit into
Conversation
survey renders the selector and then blocks reading stdin. When stdin is an open pipe (CI steps, agent shells, cron) the process hangs forever at "Select project" or "Select a service" with no error. On Windows it fails with the raw "Incorrect function." instead. Check that stdin is a terminal before every prompt and return ErrNonInteractive with the prompt text and a hint to pass flags or use -i=false. Selectors that auto-pick a single option never reach the prompter, so they keep working in scripts. Closes zeabur#278 Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Sep 30, 2026
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.
Description (required)
Every interactive prompt goes through
pkg/prompt, which calls survey. When stdin is an open pipe that never sends input (CI step, agent shell, cron), survey draws the selector and blocks forever. On Windows it fails with the rawIncorrect function.instead.This adds a stdin terminal check before each prompter method. Without a terminal it returns
prompt.ErrNonInteractive:Selectors that auto-pick the only project or service never reach the prompter, so scripts that rely on that keep working. Piping answers into a prompt (
printf 'y\n' | zeabur ...) already failed withEOFon main, so nothing that used to work is refused now.I kept #279 out of this PR. It is a separate code path: on current main
deployment log --deployment-iddoes not show the service prompt, but runtime logs then fail withserviceID is required for runtime logsbecause the command never looks up the deployment's service. I have a small fix for that and can open it separately.Testing:
pkg/prompt/prompter_test.goswaps stdin for an open pipe. Before the fix, Select and MultiSelect hit the 3s timeout on Linux (WSL Ubuntu 24.04) and returnedIncorrect function.on Windows. After the fix all six methods returnErrNonInteractiveon both.context clearandtemplate getwith stdin on an open FIFO and a dummy token: main hung untiltimeout(exit 124), this branch exits 1 right away with the message above.go test ./...,go build,golangci-lint run ./...(0 issues), gofumpt clean. I don't havemakeon this machine, so I ran the commands the Makefile wraps.Written with help from Cursor (AI). I reviewed the change and ran the tests above.
Related issues & labels (optional)
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.