fix(auth): report Ctrl-C at the login paste prompt as a cancellation - #275
AmanVarshney01 wants to merge 3 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>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Essentials Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. Summary by CodeRabbit
WalkthroughWhen readline raises Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to Ctrl-C during the paste prompt is reported as cancellation, while a completed browser callback still finishes login. No actionable merge risk is evident. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
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>
Ctrl-C at the
auth loginpaste prompt is handled by readline, which rejects withAbortErrorinstead of delivering SIGINT. The login code treated everyAbortErroras a completed browser callback. With no credential, it then returnedCLI.INTERNAL_ERROR, exit 1. This made a cancelled sign-in look like a technical failure to create-prisma.The fix checks whether the login's own abort signal fired. If it did, the browser callback won. Otherwise, the user cancelled the prompt, so the CLI returns
CLI.PROMPT_CANCELLED, exit 3.Verified in a real PTY using an isolated auth file: before,
CLI.INTERNAL_ERROR; after,CLI.PROMPT_CANCELLED. Unit tests, typecheck, lint, error-reference checks, and Windows/Ubuntu test jobs pass.The real-API e2e job is red on
SERVICE.DEPLOY_FAILED/ HTTP 500 in the service-version fixture. It fails identically on this PR and on main, which does not contain this auth change.