[codex] Structure primary auth validation failures#3471
Conversation
|
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 |
Co-authored-by: codex <codex@users.noreply.github.com>
2484157 to
302cdb8
Compare
ApprovabilityVerdict: Approved This PR refactors auth validation errors from generic Error throws to structured, typed error classes. The error conditions and user-facing messages remain unchanged - only the internal error representation is improved. Changes are well-tested and don't alter authentication logic. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: codex <codex@users.noreply.github.com>
Summary
Validation
Note
Medium Risk
Changes authentication error types and user-visible messages for non-pairing primary HTTP failures (generic operation/status text instead of API details); pairing and timeout copy is preserved.
Overview
Primary environment auth failures are split into tagged Schema errors instead of generic
Errorstrings and HTTP-derivedPrimaryEnvironmentRequestError.detailtext.Pairing and bootstrap: blank tokens throw
PrimaryEnvironmentPairingCredentialRequiredError(withprovidedLength); invalid credentials frombrowserSessionbecomePrimaryEnvironmentPairingCredentialRejectedErrorwith the same user-facing copy as before. Post-bootstrap session polling throwsPrimaryEnvironmentAuthSessionTimeoutErrorwith timing fields while gate state still surfaces the existing timeout message.Request errors:
PrimaryEnvironmentRequestErrordropsdetailand thereadHttpApiErrorMessage/ friendly-bootstrap mappers;fromCauseonly needsoperation+cause, andmessageis derived from operation and HTTP status without leaking transport text.Tests add
installDesktopBootstrap, cover blank/rejected pairing, request message derivation, and desktop bootstrap timeout; invalid-token expectations move to the new rejected-credential type.Reviewed by Cursor Bugbot for commit 1663678. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure primary auth validation failures into typed error classes
Errorthrows in primary auth flows with structured error types:PrimaryEnvironmentPairingCredentialRequiredError(blank token),PrimaryEnvironmentPairingCredentialRejectedError(invalid token), andPrimaryEnvironmentAuthSessionTimeoutError(post-bootstrap polling timeout).PrimaryEnvironmentRequestError.fromCauseby removing thedetailfield andfallbackMessageparameter; the message is now a fixed, non-leaking format:'Primary environment request failed during {operation} (HTTP {status}).'readHttpApiErrorMessageandtoFriendlyBootstrapErrorMessagehelpers, consolidating error messaging into the structured error classes.isPrimaryEnvironmentPairingCredentialRejectedError) from index.ts.Erroror a detailedPrimaryEnvironmentRequestErrorwith adetailfield will now receive one of the new structured types or a standardized message without detail.Macroscope summarized 1663678.