[codex] Structure pairing grant failures#3386
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved This PR improves error handling structure in PairingGrantStore by adding specific error classes with more context (IDs, subjects) and moving error mapping to individual operation points. No runtime behavior changes beyond error formatting - a straightforward refactor with corresponding tests. You can customize Macroscope's approvability policy. Learn more. |
Summary
Tests
vp test apps/server/src/auth/PairingGrantStore.test.tsvp checkvp run typecheckNote
Medium Risk
Touches bootstrap/pairing credential consumption in auth; behavior on success paths is unchanged but failure types and wrapping differ, which may affect downstream error mapping and logging.
Overview
Pairing grant persistence and crypto failures are now surfaced as specific tagged errors instead of generic wrappers, with pairing link id, subject, and optional label on issue/revoke failures and separate types for random generation, atomic consume, and credential lookup.
consumemapsconsumeAvailableandgetByCredentialfailures toBootstrapCredentialConsumeAvailableErrorandBootstrapCredentialLookupErrorrespectively, and drops the previous catch-all that re-wrapped unknown errors asBootstrapCredentialConsumeError. Repository/platform causes are attached at eachmapErrorsite.Tests add a mock
AuthPairingLinkRepositorylayer and assert that a failedconsumeAvailableyieldsBootstrapCredentialConsumeAvailableErrorwith the originalPersistenceSqlErrorascause.Reviewed by Cursor Bugbot for commit 6438a45. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure pairing grant failures with typed errors in
PairingGrantStoreBootstrapCredentialConsumeAvailableErrorandBootstrapCredentialLookupErrorto distinguish repository failures inPairingGrantStore.consume, preserving the underlying cause in each.PairingCredentialRandomGenerationErrorfor failures in random ID or token generation withinissueOneTimeTokenandgeneratePairingToken.PairingLinkRevokeErrorandPairingCredentialIssueErrorwith contextual fields (pairingLinkId,subject,label) and updates their messages accordingly.BootstrapCredentialInternalErrorunion to include all new error types.consumeno longer wraps all unrecognized failures intoBootstrapCredentialConsumeError; callers that matched on that catch-all will need to handle the new error types.Macroscope summarized 6438a45.