fix(amazon-bedrock): preserve inference-profile ARN model IDs unencoded in REST URLs#15377
Open
abdulmunimjemal wants to merge 1 commit into
Open
fix(amazon-bedrock): preserve inference-profile ARN model IDs unencoded in REST URLs#15377abdulmunimjemal wants to merge 1 commit into
abdulmunimjemal wants to merge 1 commit into
Conversation
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.
Fixes #14117.
Background
AWS Bedrock supports two model-id shapes in
/model/{modelId}/...REST paths:us.amazon.nova-2-lite-v1:0— these MUST be URL-encoded so the:survives path parsing.arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abc123— these MUST be passed verbatim, unencoded, or Bedrock returns400 The provided model identifier is invalid.The current code uses
encodeURIComponent(modelId)unconditionally, so case (2) breaks.Change
Introduce
encodeBedrockModelId(modelId)that returns ARNs as-is andencodeURIComponents everything else. Update the four URL-path construction sites in@ai-sdk/amazon-bedrockto use it.Note re prior PRs
PRs #14138 and #14257 attempted similar fixes but reference the old
bedrock-*.tsfilenames — they predate the package rename toamazon-bedrock-*.tsand have been untouched for over a month. This PR targets the current file layout.Tests
Added unit tests for the helper covering regular IDs, application-inference-profile ARNs, and cross-region inference-profile ARNs. Verified with
pnpm --filter @ai-sdk/amazon-bedrock test.