[codex] Structure managed relay state errors - #3264
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 |
ApprovabilityVerdict: Approved This PR refactors error classes in the managed relay module to be more structured and informative, adding contextual fields like accountId and environmentId. The changes improve error diagnostics without altering runtime control flow, and include proper URL redaction to avoid exposing secrets. No code changes detected at You can customize Macroscope's approvability policy. Learn more. |
Dismissing prior approval to re-evaluate 1d14eef
1d14eef to
713e11b
Compare
Dismissing prior approval to re-evaluate 713e11b
713e11b to
a3ae3d8
Compare
1e542ee to
62192e0
Compare
a3ae3d8 to
ad2be2d
Compare
Dismissing prior approval to re-evaluate ad2be2d
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
ad2be2d to
5944bad
Compare
9b8b72c
into
codex/audit-relay-errors-wave1
Summary
Verification
vp test packages/client-runtime/src/relay/managedRelayState.test.tsvp checkvp run typecheckNote
Low Risk
Scoped to client-runtime relay error modeling and tests; behavior is clearer failures and safer diagnostics, not new relay or auth flows.
Overview
Replaces the single generic managed relay session and snapshot errors with Effect Schema tagged error unions so callers can branch on failure kind and get structured context (account IDs, expected vs actual environment IDs).
Session path: token read failures become
ManagedRelayTokenReadErrorwith the original providercause; null tokens vs missing/wrong-account sessions are split intoManagedRelayTokenUnavailableErrorandManagedRelaySessionUnavailableError(withrequestedAccountId).Status validation: environment, endpoint, and descriptor mismatches each get their own error type with expected/actual IDs. Endpoint mismatches are built via
ManagedRelayStatusEndpointMismatchError.fromEndpoints, which usesgetUrlDiagnosticsso logs expose protocol, hostname, and URL length—not credentials, paths, query tokens, or fragments.Tests assert the new types, redaction behavior, and clearer mismatch messages; one stream test moves to
it.effectwith fibers.Reviewed by Cursor Bugbot for commit 5944bad. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure managed relay state errors into typed, secret-redacted error classes
ManagedRelaySessionErrorandManagedRelaySnapshotErrorwith discriminated unions of specificSchema.TaggedErrorClasstypes, each carrying structured context (account IDs, environment IDs, URL diagnostics).ManagedRelayTokenReadError,ManagedRelayTokenUnavailableError, andManagedRelaySessionUnavailableErrorto distinguish token read failures, absent tokens, and missing/mismatched sessions.ManagedRelayStatusEnvironmentMismatchError,ManagedRelayStatusEndpointMismatchError, andManagedRelayStatusDescriptorEnvironmentMismatchErrorfor snapshot validation; endpoint mismatches redact URL secrets, exposing only protocol, hostname, and input lengths.Effect.forkChild/Fiber.join.Macroscope summarized 5944bad.