-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Fix/anthropic beta header merge #10158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chentsulin
wants to merge
5
commits into
vercel:main
Choose a base branch
from
chentsulin:fix/anthropic-beta-header-merge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+79
−6
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3e8787f
feat(provider-utils): implement combineAndMergeMergeableHeaders
chentsulin 80f210f
fix(anthropic): use combineAndMergeMergeableHeaders instead
chentsulin 4e87648
test(anthropic): add test for merging custom anthropic-beta header
chentsulin 9359692
chore: update changeset
chentsulin 48c3538
Merge branch 'main' into fix/anthropic-beta-header-merge
chentsulin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@ai-sdk/provider-utils': patch | ||
| '@ai-sdk/anthropic': patch | ||
| --- | ||
|
|
||
| Fix the custom anthropic-beta merge issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case-sensitivity check for mergeable headers is incomplete. The code checks if a key is mergeable using case-insensitive comparison (
key.toLowerCase()) but then checks if the key exists in the result using exact casing (result[key]), which will fail to find existing keys with different casing.View Details
Analysis
Case-insensitive header merging fails with different casing
What fails:
combineAndMergeMergeableHeaders()inpackages/provider-utils/src/combine-headers.tsfails to merge headers when the same logical header is provided with different casing (e.g.,'Anthropic-Beta'and'anthropic-beta').How to reproduce:
Result: Returns object with both keys present:
Expected: Single merged header:
Root cause: Line 32 checked if a mergeable key exists using case-insensitive comparison (
key.toLowerCase()) but then searched for it in the result object using exact case matching (result[key]). This caused case-mismatched headers to not be found and merged.Impact: Users providing headers with different casing will end up with duplicate headers that may not be properly combined, potentially causing API request failures.