Skip to content

fix(auth): report Ctrl-C at the login paste prompt as a cancellation - #275

Open
AmanVarshney01 wants to merge 3 commits into
mainfrom
fix/auth-login-ctrl-c-aborts
Open

AmanVarshney01 wants to merge 3 commits into
mainfrom
fix/auth-login-ctrl-c-aborts

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Ctrl-C at the auth login paste prompt is handled by readline, which rejects with AbortError instead of delivering SIGINT. The login code treated every AbortError as a completed browser callback. With no credential, it then returned CLI.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.

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>
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Essentials

Run ID: 01908ff5-710f-4cba-99b0-863d55755bb4

📥 Commits

Reviewing files that changed from the base of the PR and between ef3695d and 540dbfe.

📒 Files selected for processing (3)
  • docs/reference/error-reference.md
  • packages/cli/src/auth/login.ts
  • packages/cli/tests/auth-login.test.ts

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

  • Bug Fixes

    • Pressing Ctrl-C at the callback URL prompt during prisma auth login now reports a prompt cancellation with exit code 3.
    • Login can complete when the browser callback arrives while the callback URL prompt is still waiting.
  • Documentation

    • Clarified that Ctrl-C at the callback URL prompt is a prompt-cancellation case.

Walkthrough

When readline raises AbortError, the login paste prompt returns null if its signal is aborted. Otherwise, it throws CLI.PROMPT_CANCELLED. Tests cover Ctrl-C cancellation and browser callback completion while the prompt waits. The error reference now documents Ctrl-C as a cancellation case and retains exit code 3.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 540db

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: reporting Ctrl-C at the login paste prompt as a cancellation.
Description check ✅ Passed The description explains the AbortError behavior, the cancellation fix, the expected exit codes, verification results, and the unrelated end-to-end failure.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npx https://pkg.pr.new/@prisma/cli@275
npx https://pkg.pr.new/@prisma/cli-engine@275

commit: 540dbfe

AmanVarshney01 and others added 2 commits September 21, 2026 16:30
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant