fix: preserve provider request headers in logs - #5257
diegosouzapw merged 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors header handling in handleChatCore to avoid variable shadowing and removes redundant header assignments. It also adds comprehensive unit tests to verify that upstream response headers (such as cf-ray and server) do not overwrite the original request headers in the providerRequest pipeline payload for both standard and streaming responses, and that Claude Code-compatible request logs preserve beta headers and summarized thinking configurations. Feedback is provided to normalize headers using normalizeHeaders before passing them to new Response to prevent potential runtime crashes on Node 24 due to undici private member access issues.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
545780c to
4fd9e01
Compare
|
#5257 is ready for maintainer review/merge. Current status:
The change is backend/logging-adjacent and all reported checks are green. |
Integrated into release/v3.8.40 — provider request headers preserved in logs; verified combo reads native Response.headers (no regression).
Purpose
Fix detailed call log Provider Request payloads so the headers shown there are the outbound provider request headers, not upstream response headers.
Changes
Root Cause
chatCore replaced the executor result
headersfield withresponse.headersafter wrapping provider responses. The detailed logger later treated that field as Provider Request headers, which made Cloudflare/Caddy response headers appear under Provider Request and hid request-only headers such asanthropic-beta.Validation
node --import tsx/esm --test tests/unit/provider-request-failure-pipeline.test.tsnode --import tsx/esm --test tests/unit/executor-default-base.test.ts tests/unit/claude-code-compatible-request.test.ts tests/unit/request-logger-endpoints.test.tsnpm run typecheck:core