[codex] Structure primary environment request failures#3409
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 refactors error handling by replacing generic errors with a structured You can customize Macroscope's approvability policy. Learn more. |
Summary
Validation
vp test apps/web/src/authBootstrap.test.ts apps/web/src/environments/primary/bootstrap.test.tsvp checkvp run typecheckNote
Medium Risk
Touches auth bootstrap, session/pairing APIs, and error types callers may catch; behavior should stay similar but failure objects and predicates changed.
Overview
Replaces ad-hoc
BootstrapHttpErrorand genericErrorthrows with a singlePrimaryEnvironmentRequestError(Effect Schema tagged error) for primary-environment HTTP calls.Each failure now carries
operation(e.g.exchange-bootstrap-credential,list-pairing-links),status, user-facingdetail, optionalpairingLinkId/sessionId, and the originalcause. Mapping is centralized inPrimaryEnvironmentRequestError.fromCause, which derives status and messages from structured HTTP errors or code-owned fallbacks; bootstrap credential exchange still applies friendly pairing-token copy viaformatDetail.isTransientBootstrapErrornow treats transient retries using the new error’sstatus.context.tsdescriptor fetch uses the same error type. Public exports addPrimaryEnvironmentRequestErrorandisPrimaryEnvironmentRequestError.The invalid-pairing-token test now asserts the structured error shape (including preserved
EnvironmentAuthInvalidErrorcause) instead of only matching a thrown message string.Reviewed by Cursor Bugbot for commit eee2f35. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Replace ad-hoc errors with structured
PrimaryEnvironmentRequestErrorin primary environment authPrimaryEnvironmentRequestError, a tagged error class withoperation,status,detail, optionalpairingLinkId/sessionId, andcausefields, replacing genericErrorandBootstrapHttpErroracross all primary environment request functions inauth.tsandcontext.ts.isPrimaryEnvironmentRequestErrortype guard from the primary environment module so callers can discriminate errors by operation and status.isTransientBootstrapErrorto useisPrimaryEnvironmentRequestErrorinstead of the now-removedisBootstrapHttpError.PrimaryEnvironmentRequestErrorinstead ofBootstrapHttpErroror genericError; callers that catch and inspect error types will need to update their checks.Macroscope summarized eee2f35.