Skip to content

fix(router): stop dropping client-sent default headers like anthropic-version#320

Merged
johntmyers merged 1 commit intomainfrom
fix/anthropic-version-header-drop
Mar 15, 2026
Merged

fix(router): stop dropping client-sent default headers like anthropic-version#320
johntmyers merged 1 commit intomainfrom
fix/anthropic-version-header-drop

Conversation

@johntmyers
Copy link
Collaborator

Summary

Fix a bug where client-sent headers that match route default_headers names (e.g. anthropic-version) are silently dropped, causing upstream API errors for third-party clients like OpenClaw.

Related Issue

N/A — reported via direct debugging session.

Changes

  • Removed default_headers names from the strip_headers list in send_backend_request (backend.rs). Only auth headers (authorization, x-api-key) and host are stripped now.
  • Added regression test proxy_forwards_client_anthropic_version_header that verifies a client-sent anthropic-version header reaches the upstream.

Root Cause

send_backend_request added default_headers names to strip_headers, which removed the client's value in the forwarding loop. The subsequent already_sent check looked at the original input headers, saw the client had sent it, and skipped injecting the route default. Neither the client's value nor the default reached the upstream.

After the fix:

  • Client sends the header → passes through forwarding, already_sent = true, default skipped. Client value wins.
  • Client omits the header → nothing to forward, already_sent = false, default injected. Route default wins.

Auth headers are still unconditionally stripped and re-injected via the route's auth mechanism — no security regression.

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

…-version

The strip_headers list in send_backend_request included default_headers
names (e.g. anthropic-version), which removed the client's value. The
already_sent check then saw the original input still contained the header
and skipped injecting the route default. Neither value reached upstream.

Remove default_headers names from strip_headers so client values pass
through. The existing already_sent guard still injects defaults only when
the client omits them.
@johntmyers johntmyers self-assigned this Mar 15, 2026
@johntmyers johntmyers requested a review from pimlock March 15, 2026 06:20
@johntmyers johntmyers merged commit 547425a into main Mar 15, 2026
9 checks passed
@johntmyers johntmyers deleted the fix/anthropic-version-header-drop branch March 15, 2026 06:53
drew pushed a commit that referenced this pull request Mar 16, 2026
…-version (#320)

The strip_headers list in send_backend_request included default_headers
names (e.g. anthropic-version), which removed the client's value. The
already_sent check then saw the original input still contained the header
and skipped injecting the route default. Neither value reached upstream.

Remove default_headers names from strip_headers so client values pass
through. The existing already_sent guard still injects defaults only when
the client omits them.
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.

2 participants