Skip to content

fix: preserve provider request headers in logs - #5257

Merged
diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.40from
rdself:coder/fix-provider-request-log-headers
Jun 28, 2026
Merged

diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.40from
rdself:coder/fix-provider-request-log-headers

Conversation

@rdself

@rdself rdself commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Purpose

Fix detailed call log Provider Request payloads so the headers shown there are the outbound provider request headers, not upstream response headers.

Changes

  • Preserve executor-returned request headers when chatCore wraps streaming and non-streaming upstream responses.
  • Keep response headers scoped to the Response object and dedup snapshot only.
  • Add regression coverage for non-streaming logs, streaming logs, and CC-compatible request defaults.

Root Cause

chatCore replaced the executor result headers field with response.headers after 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 as anthropic-beta.

Validation

  • node --import tsx/esm --test tests/unit/provider-request-failure-pipeline.test.ts
  • node --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.ts
  • npm run typecheck:core

@rdself
rdself requested a review from diegosouzapw as a code owner June 28, 2026 20:47
Copilot AI review requested due to automatic review settings June 28, 2026 20:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread open-sse/handlers/chatCore.ts Outdated
@rdself
rdself force-pushed the coder/fix-provider-request-log-headers branch from 545780c to 4fd9e01 Compare June 28, 2026 21:06
@KooshaPari

Copy link
Copy Markdown
Contributor

#5257 is ready for maintainer review/merge.

Current status:

  • Fast Quality Gates: pass
  • Unit Tests fast-path (1/2): pass
  • Unit Tests fast-path (2/2): pass
  • Vitest: pass
  • dast-smoke: pass
  • semgrep + semgrep-cloud: pass

The change is backend/logging-adjacent and all reported checks are green.

@diegosouzapw
diegosouzapw merged commit c779be6 into diegosouzapw:release/v3.8.40 Jun 28, 2026
7 checks passed
@rdself
rdself deleted the coder/fix-provider-request-log-headers branch June 29, 2026 02:48
@diegosouzapw diegosouzapw mentioned this pull request Jun 29, 2026
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
Integrated into release/v3.8.40 — provider request headers preserved in logs; verified combo reads native Response.headers (no regression).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants