Repository navigation
fix(claude): record why a native passthrough failed, without upstream message text - #6330
Conversation
…g row Carries #6295 with a maintainer privacy rework: the stored reason is limited to the HTTP status plus an allowlisted Anthropic error type, so upstream message text (which can echo account identifiers or request content) never reaches the request log or usage history. Client responses are unchanged. Co-authored-by: sh940701 <visioner2168@gmail.com>
|
✅ Deterministic PR hygiene checks passed. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Maintainer integration into |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository: lidge-jun/opencodex/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff2dc75b23
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (result.kind === "error") { | ||
| const err = result.error; | ||
| finalize(502, { closeReason: "non_stream" }); | ||
| return anthropicErrorResponse(502, `anthropic passthrough failed: ${err instanceof Error ? err.message : String(err)}`, "api_error"); | ||
| return fail(502, "non_stream", `anthropic passthrough failed: ${err instanceof Error ? err.message : String(err)}`, "api_error", "anthropic passthrough failed: upstream connection error"); |
There was a problem hiding this comment.
Classify pre-header aborts as client cancellations
When the client disconnects while the upstream request is still waiting for headers, req.signal aborts the fetch and fetchWithHeaderDeadline returns kind: "error" because its catch only distinguishes expiration from other rejections. This branch consequently records the new fixed diagnostic as an upstream connection failure with status 502, even though the cause is a client cancellation; check req.signal.aborted here and use the existing 499/client_cancel representation before assigning the connection-error reason.
Useful? React with 👍 / 👎.
Summary
Carries #6295 by @sh940701 with a maintainer privacy rework. A failed native Claude passthrough used to leave its request-log row without any reason. The row now records one.
The original PR copied the free-form upstream error message into
upstreamError. Review showed that text can echo account identifiers or request content, and secret redaction does not remove either, so both reached/api/logsandusage.jsonl. The stored reason is now built only from closed data: the HTTP status plus an allowlisted Anthropic error type (invalid_request_error,authentication_error,permission_error,not_found_error,rate_limit_error,api_error,overloaded_error,request_too_large). Unknown or malformed errors get a status-only diagnostic, and fetch failures store a fixed reason. The response relayed to the client is unchanged.Supersedes #6295.
Co-authored-by: sh940701 visioner2168@gmail.com
Verification
bun test tests/claude-integration/claude-native-passthrough.test.ts tests/test-layout.test.ts tests/ci-workflows/file-size-ratchet.test.ts: 68 pass / 0 fail on currentdev;bun x tsc --noEmitpasses. The rework lane also passed the related messages endpoint, request-log and core-lab boundary tests (234 pass / 0 fail) plusprivacy:scanandstructure:check.devtip after this landing batch.Checklist