Skip to content

fix: a per-call header replaces the SDK's header whatever its case - #187

Merged
lumpinif merged 2 commits into
mainfrom
fix/header-merge-case
Nov 27, 2026
Merged

lumpinif merged 2 commits into
mainfrom
fix/header-merge-case

Conversation

@lumpinif

@lumpinif lumpinif commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Before: RequestOptions(additional_headers={"authorization": ...}) was sent as a second header next to the SDK's Authorization; only the exact spelling replaced it.

After: a name in additional_headers replaces the SDK's header of that name in any casing.

What users see: only callers who used another casing; one header is sent instead of two.

Verified: 4 tests, one through httpx with a mock transport; 3 fail without the fix. poe check and poe test (334 passed) pass.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Bug Fixes
    • Custom headers now replace matching SDK-provided headers regardless of capitalization, preventing duplicate authorization headers in a request. Overrides apply only to the request where they are provided; requests without overrides continue to use the SDK defaults.
    • A custom User-Agent value is appended to the SDK’s User-Agent, without sending a duplicate header.

After merging #182 into this branch: User-Agent is the one exception. A caller's User-Agent, in any casing, is appended to the SDK's own and sent once, as #182 defines; it does not replace it.

RequestOptions additional_headers were merged into the SDK's headers by exact
name, so {"authorization": ...} was sent next to the SDK's Authorization as
a second header, and the same for User-Agent. A name now replaces the SDK's
header of that name in any casing, as an exactly matching name already did.
@lumpinif
lumpinif requested review from abersheeran and a lite review from Copilot November 26, 2026 11:17
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-26T11:17:36.788997Z
We couldn’t complete this review. Comment @codex review to try again.
228cc9d PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The client wrapper now replaces matching SDK headers with request-option headers regardless of casing. It appends a caller-provided User-Agent value to the SDK value. Unit tests cover both behaviors.

Changes: Request header replacement

Layer / File(s) Summary
Header merge and request coverage
src/fishaudio/core/client_wrapper.py, tests/unit/test_core.py
get_headers removes SDK headers that match additional headers case-insensitively before adding the supplied values. Tests cover Authorization casing, later requests without an override, and appending a lowercase user-agent value to the SDK User-Agent.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Possibly related PRs

Merge Risk: Minimal · up to 2f478

Per-call headers now replace the SDK's matching header whatever its casing, so callers no longer send duplicate Authorization or User-Agent headers. The change is small and covered by tests, and no merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: a per-call header passed through RequestOptions(additional_headers) now replaces the SDK's matching header regardless of letter casing. The raw summary confirms get_h…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: a per-call header passed through RequestOptions(additional_headers) now replaces the SDK's matching header regardless of letter casing. The raw summary confirms get_headers now replaces headers case-insensitively instead of adding a differently cased duplicate, with the User-Agent special case noted. The title is short, specific, and matches the objectives, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 06595814-c7e7-4f5e-99df-8dca9aaa9c2f
Commits

Reviewing files that changed from the base of the PR and between 228cc9d and 2f47828.

Files selected for processing: 2

  • src/fishaudio/core/client_wrapper.py
  • tests/unit/test_core.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/fishaudio/core/client_wrapper.py 92.81% <100.00%> (+0.19%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

🟢 Approval recommended

No active review issues remain, and the change includes centralized case-insensitive header replacement with HTTP-level coverage for authorization and user-agent overrides.

No open issues 🎉

What changed in this PR

Makes per-call additional_headers override the SDK's built-in Authorization and User-Agent headers regardless of casing, preventing duplicate headers.

Changes:

  • Filters SDK headers case-insensitively before applying per-call headers.
  • Routes request-option headers through the centralized header-merging logic.
  • Adds HTTP-level tests for authorization casing and user-agent replacement.
File Description
tests/​unit/​test_core.py Adds coverage verifying authorization and user-agent headers are overridden without duplicates across casing variations.
src/​fishaudio/​core/​client_wrapper.py Implements case-insensitive replacement of SDK headers and applies it during request preparation.

Review effort: Lite

@lumpinif
lumpinif merged commit 6156ed1 into main Nov 27, 2026
27 checks passed
@lumpinif
lumpinif deleted the fix/header-merge-case branch November 27, 2026 04:37
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