Skip to content

fix(amazon-bedrock): preserve inference-profile ARN model IDs unencoded in REST URLs#15377

Open
abdulmunimjemal wants to merge 1 commit into
vercel:mainfrom
abdulmunimjemal:fix/amazon-bedrock-arn-model-ids
Open

fix(amazon-bedrock): preserve inference-profile ARN model IDs unencoded in REST URLs#15377
abdulmunimjemal wants to merge 1 commit into
vercel:mainfrom
abdulmunimjemal:fix/amazon-bedrock-arn-model-ids

Conversation

@abdulmunimjemal
Copy link
Copy Markdown

Fixes #14117.

Background

AWS Bedrock supports two model-id shapes in /model/{modelId}/... REST paths:

  1. Bare model IDs like us.amazon.nova-2-lite-v1:0 — these MUST be URL-encoded so the : survives path parsing.
  2. Inference-profile ARNs like arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abc123 — these MUST be passed verbatim, unencoded, or Bedrock returns 400 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 and encodeURIComponents everything else. Update the four URL-path construction sites in @ai-sdk/amazon-bedrock to use it.

Note re prior PRs

PRs #14138 and #14257 attempted similar fixes but reference the old bedrock-*.ts filenames — they predate the package rename to amazon-bedrock-*.ts and 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.

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.

generateText doesn't work with AWS Bedrock application inference profile ARNs

1 participant