Clean up cloud secret error mappings#3402
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
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 |
6b4c998 to
dfc32cd
Compare
|
Closing as fully superseded by the existing stack: #3243 already removes the environment-key wrappers and adopts catchTags for secret persistence, while #3249 already removes the Cloud CLI wrapError helper, adopts catchTags for timeout handling, preserves richer structured causes, and includes focused tests. Rebasing onto #3249 produced an empty patch, so a separate PR would add no value. |
ApprovabilityVerdict: Needs human review Changes to error handling patterns in auth/cloud code paths, including narrowing which error types are caught. Auth-related code changes warrant human review regardless of apparent simplicity. You can customize Macroscope's approvability policy. Learn more. |
Summary
Effect.catchTagsfor tagged timeout and secret persistence failuresValidation
vp test apps/server/src/auth/ServerSecretStore.test.ts apps/server/src/cloud/environmentKeys.test.ts apps/server/src/cloud/CliTokenManager.test.ts(14 tests)vp check(0 errors; existing warnings only)vp run typecheckNote
Medium Risk
Touches authentication, secret persistence, and cloud link/reconcile flows with narrower error handling and changed client-visible relay failure text; regressions could mis-map failures or hide useful diagnostics despite preserved internal causes.
Overview
This PR restructures server-side error handling across authentication, on-disk secrets, Cloud CLI credentials, and T3 Connect relay calls. Tagged errors now carry actionable context (secret names/paths, scopes, session IDs, OAuth stages, DPoP proof metadata) instead of generic
resourcestrings or opaque wrappers.ServerSecretStoresplits directory vs per-secret failures, addsoperationon persist errors, narrows each method’s failure union, maps directory init failures explicitly, and usesEffect.catchTagsfor concurrent-create recovery so onlySecretStorePersistErrorwithAlreadyExistsretries.EnvironmentAuthadds fields on scope/forbidden/internal errors, dropsserverAuthCredentialReason/isServerAuthInvalidRequestError-style helpers, types each service method with specific error unions, and routes HTTP/WebSocket auth throughcatchEnvironmentAuthenticationErrorsplus per-handlercatchTagsinauth/http.ts,http.ts, andws.ts.Cloud paths remove
CliTokenManager’swrapErrorin favor of stage-scopedCloudCli*errors with preserved causes;CloudRelayRequestErrorclassifies relay HTTP failures by operation/phase and exposes stable messages that do not echo upstream transport/body text. DPoP replay mapping now includes proof/replay context.Tests assert the new fields and boundaries (including relay redaction and CLI credential stages).
Reviewed by Cursor Bugbot for commit dfc32cd. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add structured context fields to cloud secret store and auth error classes
resourcestring fields on secret store error classes with specificsecretName,secretPath, andoperationfields; renamesSecretStoreTemporaryPathErrortoSecretStoreTemporaryPathGenerationErrorand adds newSecretStoreDirectoryCreateError/SecretStoreDirectorySecureErrorclasses.EnvironmentAuth.tsand narrows per-method error union types across theEnvironmentAuth.Serviceinterface.CloudRelayConfigurationErrorandCloudRelayRequestErrorincloud/http.tsto replace generic internal server errors for relay URL and HTTP client failures, with phase and response status annotations.CloudCliTokenManagererror classes with stage, secret name, token endpoint, and callback address fields; error contracts forget,getExisting,hasCredential, andclearare now stage-specific.catchIferror handlers across auth, cloud, and WebSocket routes withEffect.catchTagstargeting specific error tags, using a newcatchEnvironmentAuthenticationErrorshelper.SecretStoreError,isServerAuthCredentialError, orisServerAuthInternalErrorunion helpers (which are removed) must now use tag-based matching.Macroscope summarized dfc32cd.