{{ message }}
Repository navigation
Conversation
`gh auth login --with-token` reads standard input until EOF. In an interactive terminal it printed nothing and appeared to hang, and a pasted token stayed visible on screen. It now fails fast with a flag error that shows the redirect form and points to `gh auth login` for pasting a token interactively. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 27852a81-0ebb-4088-b113-49705d817080
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Regression coverage does not verify the intended behavior when stdin is a terminal but stdout is piped.
1 open finding
What changed in this PR
Rejects terminal stdin for gh auth login --with-token, preventing apparent hangs and visible token entry.
Changes:
- Adds an immediate, actionable flag error for terminal stdin.
- Updates constructor tests for the new behavior and exact errors.
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+70
to
+71
This branch has not been deployed
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 #9789
Description
gh auth login --with-tokenreads a token from standard input until the input ends. A file or a pipe ends on its own, but a terminal does not. Thelogincommand never checked where standard input came from. So in a terminal without a piped token, it printed nothing and waited for Ctrl+D. It looked like it had hung. A token pasted while it waited also stayed visible on screen.Following the acceptance criteria in the issue,
--with-tokennow fails right away when standard input is a terminal. The new check runs before anything reads standard input:The error shows the redirect form. It also points to interactive
gh auth login, which already accepts a pasted token without showing it on screen:How did you test this change?
I built
ghfrom trunk at d6b82b1 and from this branch at 2de1e08. I recorded each build runninggh auth login --with-tokenin a terminal. Both runs used an empty config directory and no token environment variables.Before, the command printed nothing and waited until I pressed Ctrl+C.
After, the command printed the new error and the usage right away. It exited with status 1.
I also ran these by hand in a terminal with an empty config directory:
gh auth login --with-token --hostname example.comprinted the same error and exited with status 1.gh auth login --with-token | catprinted the same error. Only stdout was piped, so standard input was still the terminal.gh auth login --web --with-tokenstill reported the--webconflict first.HTTP 401: Bad credentials.gh auth login --hostname github.com --git-protocol ssh --skip-ssh-keystill offered Paste an authentication token, which the new hint points to.Key points
--with-tokenis meant for non-interactive input.CanPrompt(). The wait happens whenever standard input is a terminal, even when stdout is piped or prompts are disabled.gh gist create. That is why the usage follows the error.--with-token. The issue thread preferred an error over prompting in this flag, and interactivegh auth loginalready covers pasting a token.Notes for reviewers
tty, with-tokenandtty, with-token, hostnamecases in the constructor test. They now expect the error.gh auth login --with-tokenhangs #9789. It describes the visible token problem in more detail.Authorship and follow-up
Who wrote this:
Who answers review comments: