Repository navigation
fix: Anthropic AWS resolves the default fetch per request - #318
Merged
eric8810 merged 14 commits intoOct 27, 2026
Merged
Conversation
@ai-sdk/anthropic-aws 2.0.63 gives its chat model the provider name `anthropic-aws.messages` (anthropic-aws-provider.ts:246); aimux used `anthropic-aws`. A `name` setting still replaces it, and the providerOptions key stays `anthropic`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
@ai-sdk/anthropic-aws 2.0.63 configures its chat model with the same supportedUrls as @ai-sdk/anthropic: image/* and application/pdf over http(s) (anthropic-aws-provider.ts:251-254). aimux reported none, so such URLs were downloaded and inlined. Reuse the Anthropic provider's patterns. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
@ai-sdk/anthropic-aws 2.0.63 catches a missing access key or secret key and throws its guidance on providing credentials, with the setting error as the original error (anthropic-aws-provider.ts:183-209). aimux returned the bare LoadSetting error. The region is loaded before that try, so a missing region stays the setting error. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
@ai-sdk/anthropic-aws 2.0.63 rethrows a rejected credentialProvider as "AWS credential provider failed: <message>. Please ensure your credential provider returns valid AWS credentials ..." (anthropic-aws-provider.ts:151-160). aimux passed the producer's error on alone. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
With no fetch setting, @ai-sdk/anthropic-aws 2.0.63 calls `globalThis.fetch` as it is when each request is made (anthropic-aws-fetch.ts:36, :124), and the settings' own doc says the process default is resolved per request. create_anthropic_aws instead captured default_fetch() once at creation, so a later set_default_transport never reached the provider. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
This was referenced Oct 20, 2026
cunninghamcard-bit
changed the base branch from
fix/anthropic-aws-wraps-credential-provider-failures
to
master
October 20, 2026 11:07
This was referenced Oct 20, 2026
…quest Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
cunninghamcard-bit
marked this pull request as ready for review
October 24, 2026 10:31
eric8810
approved these changes
Oct 25, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
per-request fetch 解析、默认模型、supported URLs 与 pinned anthropic-aws 一致。Approve。
…quest Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
…esolves-the-default-fetch-per-request # Conflicts: # CHANGELOG.md
…esolves-the-default-fetch-per-request # Conflicts: # CHANGELOG.md
…esolves-the-default-fetch-per-request # Conflicts: # CHANGELOG.md
…esolves-the-default-fetch-per-request # Conflicts: # CHANGELOG.md
…esolves-the-default-fetch-per-request # Conflicts: # CHANGELOG.md
…esolves-the-default-fetch-per-request # Conflicts: # CHANGELOG.md
eric8810
approved these changes
Oct 27, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
Rebase is content-preserving: only master/parent merges and CHANGELOG/layout conflict resolution; tests and CI unchanged. Re-approving current head.
…esolves-the-default-fetch-per-request # Conflicts: # CHANGELOG.md
35 of 70 tasks
eric8810
approved these changes
Oct 27, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
Rebase verified content-preserving: only master/parent merges and CHANGELOG/layout conflict resolution; CI 16/16. Re-approving current head.
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.
Summary
Fixes the 5 behaviour differences in Anthropic AWS found while porting the upstream tests. Each difference is its own commit (listed below) and adds a test that fails on master and a CHANGELOG
Fixedentry. They were separate PRs (#314, #315, #316, #317 and this one). To keep one fix PR per vendor, the others are closed and this PR carries all of them. The Anthropic AWS test PR (#319) stacks on this branch. Part of the #276 list.77933f11198315f4d1776d9eb7a53e9e966ad7fd1. Anthropic AWS models are named anthropic-aws.messages
Before: an Anthropic AWS model created without a
namesetting reportedprovider() == "anthropic-aws".After: as in
@ai-sdk/anthropic-aws2.0.63, it reports"anthropic-aws.messages". Anamesetting still replaces it, and the providerOptions key staysanthropic.Found while porting the upstream Anthropic AWS tests (case
anthropicAws provider - model identity › sets the provider name to anthropic-aws.messages on the model).How it works today
What this PR changes
Tests (
tests/anthropic_aws_settings_test.rs):the_default_provider_name_is_anthropic_aws_messageschecks the default and a named provider; on master it fails withleft: "anthropic-aws",right: "anthropic-aws.messages". The upstream case is ported in the Anthropic AWS test PR.Docs: CHANGELOG
Fixed.Note: Nothing else in the repository reads the default name.
2. Anthropic AWS models accept image and PDF URLs
Before: an Anthropic AWS model reported no supported URLs, so an
http(s)image or PDF in a prompt was downloaded and sent inline.After: as in
@ai-sdk/anthropic-aws2.0.63, it supportsimage/*andapplication/pdfoverhttp(s), the same patterns as the Anthropic provider, so those URLs go to the Messages API as they are.Found while porting the upstream Anthropic AWS tests (
supportedUrls › should support image URLsand› should support application/pdf URLs).How it works today
What this PR changes
Tests (
tests/anthropic_aws_settings_test.rs):models_support_http_image_and_pdf_urlsexpects exactlyimage/*andapplication/pdf, an https image and an http PDF supported, an ftp URL not; on master it fails withleft: []. The upstream cases are ported in the Anthropic AWS test PR.Docs: CHANGELOG
Fixed.Note: Vertex's Claude models also report no supported URLs (
vertex/anthropic_model.rs:75); whether that matches@ai-sdk/google-vertexis checked when that package is ported.3. Anthropic AWS explains missing SigV4 credentials
Before: an Anthropic AWS request signed with the
AWS_*environment credentials failed with the bareLoadSettingerror whenAWS_ACCESS_KEY_IDorAWS_SECRET_ACCESS_KEYwas missing.After: as in
@ai-sdk/anthropic-aws2.0.63, a missing access key fails with the guidanceAWS SigV4 authentication requires AWS credentials. Please provide either: 1. … 4. …and a missing secret key withAWS SigV4 authentication requires both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. …, each ending with the setting error asOriginal error:. The error isAiMuxError::Other, as upstream throws a plainError. A missing region is stillLoadSetting, since upstream loads it before thattry. Nothing is sent in either case. The four options name aimux's settings (AnthropicAwsAuth::SigV4,AnthropicAwsAuth::ApiKey) where upstream names its JS options.Found while porting the upstream Anthropic AWS tests (
SigV4 path › throws a guided error when SigV4 credentials are missing).How it works today
What this PR changes
Tests (
tests/anthropic_aws_settings_test.rs):a_missing_sigv4_key_fails_with_guidancechecks both messages and that nothing is sent; on master it fails witha missing access key is the guidance error: LoadSetting { env_var: "AWS_ACCESS_KEY_ID", name: "access_key_id" }.default_auth_is_the_api_key_variable_else_sigv4_from_the_environmentasserted theLoadSettingerror and now asserts the guidance. The upstream case is ported in the Anthropic AWS test PR.Docs: CHANGELOG
Fixed; theauthsetting's doc names the new error.Note: Bindings no longer get
EnvVarfor these two cases, since the error is no longer aLoadSetting; this matches upstream, where the setting error only survives inside the message.4. Anthropic AWS wraps credential provider failures
Before: an Anthropic AWS credential producer (
AnthropicAwsAuth::SigV4with a future or async function) that failed was reported with its own error only:API call error: failed to resolve AWS credentials: STS denied.After: as in
@ai-sdk/anthropic-aws2.0.63, the error saysAWS credential provider failed: STS denied. Please ensure your credential provider returns valid AWS credentials with access_key_id and secret_access_key.(upstream:accessKeyId and secretAccessKey properties). Nothing is sent.Found while porting the upstream Anthropic AWS tests (
SigV4 path › wraps credential provider rejections with a guided message).How it works today
What this PR changes
Tests (
tests/anthropic_aws_settings_test.rs):a_failing_credential_producer_is_reported_with_guidance; on master it fails withAPI call error: failed to resolve AWS credentials: STS denied. The upstream case is ported in the Anthropic AWS test PR.Docs: CHANGELOG
Fixed.Note: The message still arrives inside
AiMuxError::ApiCall, withfailed to resolve AWS credentials:before it: the sharedSigV4Fetchturns any credential failure into a transport error, for Bedrock and Polly too. Upstream throws a plainError. Changing that is a provider-utils change for all three AWS providers, not this fix; the upstream test checks the message and passes.5. Anthropic AWS resolves the default fetch per request
Before: an Anthropic AWS provider created with no
fetchsetting kept the process default transport current at creation, so a laterset_default_transportnever reached it, although thefetchsetting's doc says the default is resolved per request.After: as in
@ai-sdk/anthropic-aws2.0.63, which readsglobalThis.fetchon each call, every request (API key and SigV4 alike) uses the default transport current when it is made. Creating a provider no longer acquires the default transport, so it no longer freezes the startup proxy configuration either; the first request does.Found while porting the upstream Anthropic AWS tests (
createApiKeyFetchFunction › should resolve default fetch lazily when no custom fetch provided).How it works today
What this PR changes
Tests (
tests/anthropic_aws_settings_test.rs):the_default_transport_is_looked_up_per_requestcreates the provider while the default transport points at a closed port, then points it at a local plain-HTTP proxy that answers; on master the request goes to the closed port and fails witherror sending request for url (http://example.com/v1/messages). The upstream case is ported in the Anthropic AWS test PR.Docs: CHANGELOG
Fixed.Note: Bedrock and Polly capture
default_fetch()at creation the same way (bedrock/mod.rs:417,aws_polly.rs:288); they are fixed when their packages are ported, if their upstream tests show the same.Type of change
Checklist
cargo +1.99 fmt -p aimux-providers -- --checkpassescargo +1.99 clippy -p aimux-providers --lib --tests -- -D warningspassescargo +1.99 test -p aimux-providers --test anthropic_aws_settings_testpasses (9)scripts/check_provider_boundaries.shpassesNotes for reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5