--interactive does not fall back to line prompts when stdin/stdout are not TTYs
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 67/100
Research direction
Read internal/interactive/policy.go and the help text in internal/cli/root.go, then inspect tests/contract/porcelain_interactive_test.go. Start by tracing how --interactive, TTY detection, and the prompter determine whether prompts activate; add the subprocess pipe contract coverage requested in the issue. Done means piped input prompts when --interactive is enabled while default and --no-interactive behavior remain non-interactive.
Written by the indexing model from the issue text.
Description
Description of the bug:
Summary
The root help says --interactive will prompt for missing inputs and that forms fall back to line prompts on stdin when running off-TTY. However, with piped/non-TTY stdin and stdout, the CLI exits on missing required arguments without prompting or consuming the input.
Reproduction
Build the current main branch, then run:
go build -o /tmp/gemini-api ./cmd/gemini-api
printf '/tmp/no-such-file.png\nwhat is this?\n' | \
/tmp/gemini-api --interactive --dry-run --api-key k \
--server-url https://example.invalid --color never analyze
printf 'exit=%s\n' "$?"
Actual result: exit code 2, followed by Error: missing required flag --input .... No prompt is shown and the piped answers are not consumed.
Expected result: when --interactive is explicitly enabled, non-TTY stdin should use the documented line-prompt fallback. The default and --no-interactive behavior should remain non-interactive.
Evidence
- The help text documents the off-TTY fallback: https://github.com/google-gemini/gemini-api-cli/blob/3dcbb6e542c222dad1e6f5b6e43cb390561d0cca/internal/cli/root.go#L169-L173
- The policy requires either a TTY pair or an injected prompter, so a normal piped process does not enter the prompt path: https://github.com/google-gemini/gemini-api-cli/blob/3dcbb6e542c222dad1e6f5b6e43cb390561d0cca/internal/interactive/policy.go#L49-L90
- Existing interactive tests use an injected prompter and do not cover the real off-TTY stdin path: https://github.com/google-gemini/gemini-api-cli/blob/3dcbb6e542c222dad1e6f5b6e43cb390561d0cca/tests/contract/porcelain_interactive_test.go#L94-L184
Suggested fix
Align the activation policy with the documented behavior and add a subprocess/pipe contract test. Please preserve the existing TTY interface, default non-interactive behavior, and --no-interactive behavior.
Actual vs expected behavior:
No response
Any other information you'd like to share?
No response
- Dominant language
- Go
- Stars
- 3k
- Forks
- 219
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 66
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google-gemini/gemini-api-cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
google-gemini/gemini-api-cli#247 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
google-gemini/gemini-api-cli#231 · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
google-gemini/gemini-api-cli#227 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google-gemini/gemini-api-cli#221 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
google-gemini/gemini-api-cli#241 ·
Maintainers usually reply within 1 day
All issues in google-gemini/gemini-api-cli
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
pg-sharding/spqr#3314 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 80/100
slavakurilyak/awesome-ai-agents#1051 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
zalando/postgres-operator#3257 ·
Maintainers usually reply within 2 days