fix(amazon-bedrock): skip encodeURIComponent for ARN model IDs#14138
Open
Gdhanush-13 wants to merge 1 commit into
Open
fix(amazon-bedrock): skip encodeURIComponent for ARN model IDs#14138Gdhanush-13 wants to merge 1 commit into
Gdhanush-13 wants to merge 1 commit into
Conversation
ARN-style model IDs (e.g. application inference profile ARNs) contain slashes and colons that must remain unencoded in the Bedrock REST API URL path. encodeURIComponent encodes these characters, causing Bedrock to reject the request with 'The provided model identifier is invalid'. When the model ID starts with 'arn:', skip URL encoding and use the raw ARN directly. Standard model IDs (e.g. 'us.amazon.nova-2-lite-v1:0') continue to be encoded as before. Applied to all four URL construction sites: - bedrock-chat-language-model.ts - bedrock-image-model.ts - bedrock-embedding-model.ts - anthropic/bedrock-anthropic-provider.ts Fixes vercel#14117
92eabf6 to
270e1ac
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Fixes #14117 -
@ai-sdk/amazon-bedrockfails withThe provided model identifier is invalidwhen using application inference profile ARNs as model IDs.Root Cause
The provider constructs REST API URLs by passing model IDs through
encodeURIComponent. For standard model IDs likeus.amazon.nova-2-lite-v1:0, this produces valid URLs. For ARN-style IDs likearn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abc123xyz, the slashes and colons get percent-encoded, which Bedrock's API rejects.Fix
When the model ID starts with
arn:, skipencodeURIComponentand use the raw ARN directly in the URL path. Standard model IDs continue to be encoded as before.Applied to all four URL construction sites:
bedrock-chat-language-model.tsbedrock-image-model.tsbedrock-embedding-model.tsanthropic/bedrock-anthropic-provider.ts