Repository navigation
[codex] Structure client RPC unavailable errors #3260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
juliusmarminge
merged 4 commits into
codex/redact-dpop-request-target
from
codex/client-rpc-error-context
Jun 20, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f255391
structure client RPC unavailable errors
juliusmarminge ee6201f
Preserve typed RPC retry classification
juliusmarminge 3a308b8
fix(client-runtime): bound RPC transport diagnostics
juliusmarminge 0c5fe3c
test(client-runtime): focus error mapping coverage
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,72 +1,13 @@ | ||
| import { EnvironmentAuthInvalidError } from "@t3tools/contracts"; | ||
| import { RelayAuthInvalidError } from "@t3tools/contracts/relay"; | ||
| import { describe, expect, it } from "@effect/vitest"; | ||
|
|
||
| import { mapManagedRelayError, mapRemoteEnvironmentError } from "./errors.ts"; | ||
| import * as ManagedRelay from "../relay/managedRelay.ts"; | ||
| import { mapRemoteEnvironmentError } from "./errors.ts"; | ||
| import { | ||
| RemoteEnvironmentAuthFetchError, | ||
| RemoteEnvironmentAuthUndeclaredStatusError, | ||
| } from "../rpc/http.ts"; | ||
|
|
||
| describe("connection error mapping", () => { | ||
| it("retains the managed relay request as the cause when classifying a protected error", () => { | ||
| const relayError = new RelayAuthInvalidError({ | ||
| code: "auth_invalid", | ||
| reason: "invalid_bearer", | ||
| traceId: "relay-trace-id", | ||
| }); | ||
| const source = new ManagedRelay.ManagedRelayRequestFailedError({ | ||
| action: "connect relay environment", | ||
| cause: relayError, | ||
| relayError, | ||
| traceId: relayError.traceId, | ||
| }); | ||
|
|
||
| const error = mapManagedRelayError(source); | ||
|
|
||
| expect(error).toMatchObject({ | ||
| _tag: "ConnectionBlockedError", | ||
| reason: "authentication", | ||
| traceId: "relay-trace-id", | ||
| }); | ||
| expect(error.cause).toBe(source); | ||
| }); | ||
|
|
||
| it("retains a managed relay timeout and its structured activity", () => { | ||
| const source = new ManagedRelay.ManagedRelayRequestTimeoutError({ | ||
| activity: "Relay environment connection", | ||
| timeoutMs: 10_000, | ||
| }); | ||
|
|
||
| const error = mapManagedRelayError(source); | ||
|
|
||
| expect(error).toMatchObject({ | ||
| _tag: "ConnectionTransientError", | ||
| reason: "timeout", | ||
| }); | ||
| expect(error.cause).toBe(source); | ||
| expect(source.activity).toBe("Relay environment connection"); | ||
| }); | ||
|
|
||
| it("retains structured remote authorization failures", () => { | ||
| const source = new EnvironmentAuthInvalidError({ | ||
| code: "auth_invalid", | ||
| reason: "invalid_credential", | ||
| traceId: "environment-trace-id", | ||
| }); | ||
|
|
||
| const error = mapRemoteEnvironmentError(source); | ||
|
|
||
| expect(error).toMatchObject({ | ||
| _tag: "ConnectionBlockedError", | ||
| reason: "authentication", | ||
| traceId: "environment-trace-id", | ||
| }); | ||
| expect(error.cause).toBe(source); | ||
| }); | ||
|
|
||
| it("retains local transport failures without deriving their message from the cause", () => { | ||
| it("keeps transport diagnostics structured and redacted", () => { | ||
| const transportCause = new Error("sensitive transport implementation detail"); | ||
| const requestUrl = | ||
| "https://environment-user:[email protected]/private/session?access_token=environment-secret#environment-fragment"; | ||
|
|
@@ -82,8 +23,6 @@ describe("connection error mapping", () => { | |
| _tag: "ConnectionTransientError", | ||
| reason: "network", | ||
| }); | ||
| expect(error.cause).toBe(source); | ||
| expect(source.cause).toBe(transportCause); | ||
| expect(source).toMatchObject({ | ||
| requestUrlInputLength: requestUrl.length, | ||
| requestUrlProtocol: "https:", | ||
|
|
@@ -102,7 +41,7 @@ describe("connection error mapping", () => { | |
| } | ||
| }); | ||
|
|
||
| it("retains the HTTP client cause for undeclared statuses", () => { | ||
| it("keeps undeclared status diagnostics structured and redacted", () => { | ||
| const cause = new Error("upstream response metadata"); | ||
| const requestUrl = | ||
| "https://environment-user:[email protected]/private/session?access_token=environment-secret#environment-fragment"; | ||
|
|
@@ -114,7 +53,6 @@ describe("connection error mapping", () => { | |
| requestUrlProtocol: "https:", | ||
| requestUrlHostname: "environment.example.test", | ||
| }); | ||
| expect(error.cause).toBe(cause); | ||
| expect(error).not.toHaveProperty("requestUrl"); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.