[codex] improve server auth error context#3240
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: Needs human review Changes to authentication error handling in the auth package warrant human review, even though the modifications appear to only add contextual information to error messages and improve type precision without altering authentication logic. You can customize Macroscope's approvability policy. Learn more. |
Summary
Validation
Note
Medium Risk
Touches authentication error handling and HTTP/WebSocket boundaries across the server; behavior should be equivalent but any missed catch tag could change client-visible errors.
Overview
This PR enriches server auth tagged errors with correlation fields (subjects, scopes, session/pairing-link IDs, DPoP proof metadata, credential kind) and updates messages to include that context while keeping the original
cause.EnvironmentAuthnow exposes per-operation error unions instead of a broadServerAuthInternalError, addsServerAuthAuthenticationError/ internal auth error types, and removesisServerAuthCredentialError,serverAuthCredentialReason, and similar predicate/reason helpers. Failures like scope mismatch and self-revocation now carry requested vs granted scopes and current vs target session IDs.HTTP, WebSocket, and raw routes use a shared
catchEnvironmentAuthenticationErrorsplusEffect.catchTagson auth endpoints so each failure maps to the right client response or internal reason. DPoP replay mapping takes explicit proof context; tests assert the new fields.Reviewed by Cursor Bugbot for commit 4ec1665. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add contextual fields to server auth error classes for improved error diagnostics
subject,scopes,sessionId,credentialKind) and updates error messages to include them.catchEnvironmentAuthenticationErrorshelper in http.ts that centralizes auth error-to-HTTP-response mapping across all API endpoints, WS upgrade, and raw routes.EnvironmentAuth.Contextservice methods so callers receive specific error tags rather than broadServerAuthInternalError.getSessionStateno longer downgrades validation/internal errors to unauthenticated — onlyServerAuthMissingCredentialErrorandServerAuthInvalidCredentialErrorare treated as unauthenticated.proofKeyThumbprint,proofId, andreplayKeyfor replay state and key calculation failures.EnvironmentAuthmethods will see renamed/narrowed error tag shapes.Macroscope summarized 4ec1665.