[codex] Structure cloud CLI token errors#3249
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 adds structured context fields (stage, secretName, tokenEndpoint, etc.) to CLI token error classes for better debugging, adds corresponding unit tests, and removes error handlers that are no longer needed due to narrower type signatures. No runtime behavior changes. You can customize Macroscope's approvability policy. Learn more. |
Summary
Validation
vp test apps/server/src/cloud(33 tests)vp check(passes with 20 pre-existing warnings)vp run typecheckStacked on #3246 so the cloud HTTP error boundary lands first.
Note
Medium Risk
Touches OAuth credential storage and refresh on the CLI link path; behavior is mostly error shaping and typing, but mis-handled failures could affect link/reconcile diagnostics or error propagation.
Overview
Cloud CLI token errors are reworked so failures keep the original cause while carrying secret name, pipeline stage, and optional OAuth/callback context (token endpoint, redirect URI, loopback host/port, timeout).
The generic
wrapErrorhelper is removed in favor of directmapErrormappings at each step (read/decode, refresh, login, persist, clear). Service methods now expose narrower error channels (clear→ removal only,hasCredential→ read only, etc.), andreconcileDesiredCloudLinkin cloud HTTP only catchesCloudCliCredentialRefreshErrorfromgetExisting(other CLI error tags drop out of that boundary).Tests cover removal, credential read, and malformed persisted-token decode paths, asserting tags, preserved causes, and user-facing messages.
Reviewed by Cursor Bugbot for commit dfc32cd. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure cloud CLI token manager errors with lifecycle stage and context
CloudCliTokenManagererror types with lifecycle stage, secret name, token endpoint, and callback address fields to replace the previous genericCloudCliTokenManagerError.fromCredentialRead,fromCredentialPersist) on each error class to classify failures by stage during refresh, read, and authorization flows.get,getExisting,hasCredential,clear) to the specific error types relevant to that operation.wrapErrorhelper and replaces it with explicitEffect.mapError/catchTagscalls throughoutCliTokenManager.ts.http.tsto drop catch handlers for error tags that no longer appear in the error union of the affected methods.Macroscope summarized dfc32cd.