fix(auth): report Ctrl-C at the login paste prompt as a cancellation - #275
Draft
AmanVarshney01 wants to merge 2 commits into
Draft
AmanVarshney01 wants to merge 2 commits into
AmanVarshney01 wants to merge 2 commits into
Conversation
On a TTY, `auth login` races the browser's loopback callback against a
readline prompt for a pasted callback URL. readline holds the terminal in
raw mode, so Ctrl-C there never becomes a SIGINT the engine could record.
readline closes the interface and rejects the question with its own
AbortError while the login's paste signal is still live.
The prompt treated every AbortError as "the browser callback won the
race", so login resolved with no tokens and the run settled as
CLI.INTERNAL_ERROR ("Sign-in finished without producing a credential."),
exit 1. A user cancelling sign-in was reported as a CLI bug.
The paste signal's own `aborted` state now decides: aborted means the
login is over and prompting stops, as before. An AbortError with the
signal still live is the user's Ctrl-C and throws CLI.PROMPT_CANCELLED,
the code the engine already settles as a user cancellation (exit 3) for
Ctrl-C at its own raw-mode prompts. The loopback server and the readline
interface are still torn down by the existing finally blocks. The
browser-won path and the wrong-paste re-prompt are unchanged.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
commit: |
Shorten the two comments in the paste prompt's abort handling, drop the error-conventions paragraph and the parenthetical in the CLI.PROMPT_CANCELLED reference entry, and keep only the two tests that guard the change: Ctrl-C at the prompt cancels, and the browser callback still wins while the prompt waits. The engine already tests that the code exits 3. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Ctrl-C at the
auth login"Paste the callback URL" prompt never becomes a SIGINT (readline holds the terminal in raw mode); readline rejects the question with its ownAbortError.readPastedCallbackUrltreated every AbortError as "the browser callback won", so login finished with no tokens and settled asCLI.INTERNAL_ERROR("Sign-in finished without producing a credential."), exit 1. Callers such as create-prisma recorded a cancelled sign-in as a technical failure.The paste signal's own
abortedstate now decides: aborted means the login is over; otherwise it is the user's Ctrl-C and throwsCLI.PROMPT_CANCELLED, which the engine already settles as exit 3 for Ctrl-C at its own prompts.Note for callers: this exits 3, not 130. Branch on the code (
CLI.PROMPT_CANCELLED/CLI.ABORTED), not the exit code.Verified in a real pty with the built binary: before
[CLI.INTERNAL_ERROR]exit 1, after[CLI.PROMPT_CANCELLED]exit 3. Lint, typecheck, cli tests andcheck:error-referencepass. Not covered: Windows/Linux ptys.🤖 Generated with Claude Code