fix(auth): give each login failure its own error code and stage - #442
Draft
djgould wants to merge 1 commit into
Draft
fix(auth): give each login failure its own error code and stage#442djgould wants to merge 1 commit into
djgould wants to merge 1 commit into
Conversation
Every failure in the browser-callback phase of `clerk auth login` was a plain `Error`, and `telemetryResultForError` only reads a code off `CliError` and `ApiError` — so a timed-out wait, an OAuth provider error, a state mismatch, a missing authorization code, and a loopback bind failure all landed in the warehouse as `unexpected_error`, indistinguishable from each other and from every other uncaught throw. Types those five sites as `CliError` with distinct codes, and instruments login with stage markers (session_check → awaiting_callback → token_exchange → store → done) so an abandoned browser wait is attributable to the step it stopped at. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: a3d8784 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Stacked on #441 — base is
devin/init-telemetry-stages, since this needs thesetTelemetryStagehelper and theERROR_CODEblock that PR adds. Retarget tomainonce #441 merges.clerk auth loginreported every browser-phase failure as a singleunexpected_error. All five rejection sites in the callback flow threw a plainError, andtelemetryResultForErroronly reads.codeoffCliErrorandApiError— so everything else fell through to the catch-all, mixed in with every other uncaught throw in the CLI.unexpected_errorauth_timeoutunexpected_erroroauth_provider_errorstatemismatchunexpected_erroroauth_state_mismatchunexpected_erroroauth_no_codeunexpected_errorcallback_bind_failedToken exchange already threw
ApiErrorand was never part of the problem.Also adds stage markers to login —
session_check → awaiting_callback → token_exchange → store → done— so an abandoned run is attributable to the step it stopped at. That matters most forawaiting_callback: prior analysis put 27–36% of login flows as never completing token exchange, with the 2-minute timeout provably binding, and until now those were indistinguishable from genuine breakage.No disclosure change needed:
error_codeandstageare already covered by the README and the first-run notice, and this adds no new collected field.Tests
8 new, all mutation-checked — each fails when the code or marker it covers is reverted. The timeout case captures the deadline callback via a
setTimeoutspy so it runs without waiting two minutes.Verification
typecheck,lint,format:checkclean; 2678 pass / 0 fail. E2E not run locally (needs 1Password-injected secrets).🤖 Generated with Claude Code