Skip to content

fix: drop empty Bedrock token and runtime-host base URL from CLI env - #1902

Open
WeAreResilience wants to merge 1 commit into
anthropics:mainfrom
WeAreResilience:fix/1896-bedrock-base-url
Open

WeAreResilience wants to merge 1 commit into
anthropics:mainfrom
WeAreResilience:fix/1896-bedrock-base-url

Conversation

@WeAreResilience

Copy link
Copy Markdown
Contributor

Summary

Fixes #1896. With use_bedrock: "true" and an application inference profile ARN as the model, Claude Code could not resolve the profile's backing model because of two values the run step passes to the CLI:

  • ANTHROPIC_BEDROCK_BASE_URL defaulted to https://bedrock-runtime.<region>.amazonaws.com. Claude Code (2.1.299, the pinned version) builds its control-plane BedrockClient with endpoint: ANTHROPIC_BEDROCK_BASE_URL when the variable is set, so GetInferenceProfile went to bedrock-runtime. Unset, that client uses bedrock.<region>.amazonaws.com, and the runtime client already defaults to the bedrock-runtime host.
  • AWS_BEARER_TOKEN_BEDROCK was exported as "" when the workflow did not set it. The AWS SDK's auth scheme selector picks httpBearerAuth whenever AWS_BEARER_TOKEN_<signing name> exists in the environment, so the OIDC SigV4 credentials were not used and the lookup failed with "request could not be signed with token since the token is not defined".

Both action.yml files now pass ANTHROPIC_BEDROCK_BASE_URL through unchanged, and parseSdkOptions drops either variable from the CLI env when it is empty or whitespace. A workflow that sets either value keeps it as before. The base-action README note on the endpoint is updated to match.

Not tested against a real Bedrock account. I reproduced the signing error with the bundled 2.1.299 CLI, fake SigV4 credentials, AWS_BEARER_TOKEN_BEDROCK= and an inference profile ARN, and read the endpoint and auth selection in that binary.

Test plan

  • bun test in the repo root and in base-action/ (no new failures; the root's 27 git-based failures are the same set on unmodified main in my environment)
  • bun run typecheck (root and base-action/) and bun run format:check
  • New parseSdkOptions tests: each variable is dropped when empty or whitespace, kept when set, and not added when unset; the drop cases fail without the change
  • New metadata tests for both action.yml files assert ANTHROPIC_BEDROCK_BASE_URL maps straight from env; they fail on main

@kimnamu

kimnamu commented Nov 3, 2026

Copy link
Copy Markdown

Thanks for this PR and for spelling out which client reads which variable; that made it quick to re-check against the Claude Code bumps since #1896.

On main 4845bac (Claude Code 2.1.317, v1.0.267) the base URL half still reproduces against real Bedrock. The empty-token half stopped reproducing in Claude Code 2.1.314 (v1.0.265), and I couldn't find a CHANGELOG line for that change.

--model <application inference profile ARN> Claude Code Profile lookup
Stub, AWS_BEARER_TOKEN_BEDROCK="" + SigV4 keys 2.1.301, 2.1.309, 2.1.312 never sent: request could not be signed with token
Stub, AWS_BEARER_TOKEN_BEDROCK="" + SigV4 keys 2.1.314, 2.1.316, 2.1.317 GET /inference-profiles/<arn> sent, SigV4-signed
Real Bedrock, ANTHROPIC_BEDROCK_BASE_URL = runtime host (default from action.yml L354, base-action/action.yml L221) 2.1.317 Failed to resolve … backing model, session still returns OK
Real Bedrock, base URL unset 2.1.317 no lookup errors

So on current main, the ANTHROPIC_BEDROCK_BASE_URL change is the part that still fixes #1896. The AWS_BEARER_TOKEN_BEDROCK drop no longer changes the CLI's own lookups on 2.1.314+. Keeping it looks harmless to me, but I'd leave that to you and the maintainers.

The PR still merges onto 4845bac without conflicts:

### main 4845bac src + PR tests
(fail) action metadata > should pass ANTHROPIC_BEDROCK_BASE_URL through without a runtime-host default
(fail) base action metadata > should pass ANTHROPIC_BEDROCK_BASE_URL through without a runtime-host default
(fail) parseSdkOptions > environment variables passthrough > should drop AWS_BEARER_TOKEN_BEDROCK from env when it is empty
(fail) parseSdkOptions > environment variables passthrough > should drop AWS_BEARER_TOKEN_BEDROCK from env when it is whitespace-only
(fail) parseSdkOptions > environment variables passthrough > should drop ANTHROPIC_BEDROCK_BASE_URL from env when it is empty
(fail) parseSdkOptions > environment variables passthrough > should drop ANTHROPIC_BEDROCK_BASE_URL from env when it is whitespace-only
 76 pass
 6 fail
### main 4845bac + #1902 merged
 82 pass
 0 fail
full bun test: Ran 976 tests across 58 files, 976 pass, 0 fail
typecheck OK
format:check OK
Run output

Stub endpoint, fake SigV4 keys, AWS_BEARER_TOKEN_BEDROCK="", the CLI bundled with each Agent SDK release. There is no 2.1.313 release of the CLI or the Agent SDK, so 2.1.314 is the first build without the signing error.

## 2.1.312 (Claude Code)
POST /model/arn:aws:bedrock:us-east-1:123456789012:application-inference-profile%2Fstubprofile01/invoke-with-response-stream  auth=AWS4-HMAC-SHA256
[ERROR] Bedrock ListInferenceProfiles failed: request could not be signed with `token` since the `token` is not defined
[ERROR] Failed to resolve Bedrock inference profile backing model for arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/stubprofile01: request could not be signed with `token` since the `token` is not defined
## 2.1.314 (Claude Code)
GET /inference-profiles  auth=AWS4-HMAC-SHA256
GET /inference-profiles/arn%3Aaws%3Abedrock%3Aus-east-1%3A123456789012%3Aapplication-inference-profile%2Fstubprofile01  auth=AWS4-HMAC-SHA256
POST /model/arn:aws:bedrock:us-east-1:123456789012:application-inference-profile%2Fstubprofile01/invoke-with-response-stream  auth=AWS4-HMAC-SHA256

Real Bedrock, Claude Code 2.1.317, a throwaway application profile copied from us.anthropic.claude-haiku-4-5-20251001-v1:0 (deleted afterwards), Bedrock API key auth. Only ANTHROPIC_BEDROCK_BASE_URL differs between the two runs:

### ANTHROPIC_BEDROCK_BASE_URL runtime-host
  result='OK' is_error=False
  [ERROR] "Bedrock ListInferenceProfiles failed: JSON Parse error: Unrecognized token '<' …
  [ERROR] "Failed to list Bedrock inference profiles, falling back to hardcoded models: JSON Parse error: Unrecognized token '<' …
  [ERROR] "Failed to resolve Bedrock inference profile backing model for arn:aws:bedrock:us-east-1:<acct>:application-inference-profile/<id>: JSON Parse error: Unrecognized token '<' …
### ANTHROPIC_BEDROCK_BASE_URL unset
  result='OK' is_error=False

Two CHANGELOG entries look related but don't cover this lookup. 2.1.309 "Fixed fine-grained tool streaming staying off on Amazon Bedrock when ANTHROPIC_BEDROCK_BASE_URL is set to the default bedrock-runtime.<region>.amazonaws.com endpoint" is about streaming (the 2.1.317 real run above still fails the lookup). 2.1.317 "Fixed stdio MCP servers receiving an empty AWS_BEARER_TOKEN_BEDROCK" is about MCP servers; the CLI's own lookup changed earlier, in 2.1.314.

Agent SDK 0.3.317 still spawns the CLI with a copy of options.env (gt=L?{...L}:{...process.env}), so the deletes in parseSdkOptions reach it.

@WeAreResilience

Copy link
Copy Markdown
Contributor Author

Thanks @kimnamu, that's a really thorough re-check. Good to know the empty-token part stopped reproducing in Claude Code 2.1.314 while the ANTHROPIC_BEDROCK_BASE_URL default still breaks the profile lookup on 2.1.317.

Since the base URL change is the part that still fixes #1896, I'm happy to narrow the change to just that if the maintainers would rather keep it minimal. Otherwise I'll leave the empty-token drop in as a harmless guard. Just let me know which you prefer.

@WeAreResilience

Copy link
Copy Markdown
Contributor Author

Ready for review whenever you have a moment; happy to narrow to only the ANTHROPIC_BEDROCK_BASE_URL change if that is preferred.

action.yml defaulted ANTHROPIC_BEDROCK_BASE_URL to the bedrock-runtime
host. Claude Code also uses that variable as the endpoint of its Bedrock
control-plane client, so GetInferenceProfile went to bedrock-runtime and
application inference profiles never resolved to a backing model.

The step also exported AWS_BEARER_TOKEN_BEDROCK as an empty string when
the workflow did not set it. The AWS SDK selects bearer auth whenever
that variable exists, so SigV4 credentials from OIDC were ignored for
those calls.

Pass ANTHROPIC_BEDROCK_BASE_URL through unchanged and drop either value
from the CLI env when it is empty, so Claude Code falls back to its
regional defaults and SigV4.

Fixes anthropics#1896

Signed-off-by: David Billiot <info@we-are-resilience.com>
@WeAreResilience
WeAreResilience force-pushed the fix/1896-bedrock-base-url branch from 8fe4075 to c7f113f Compare November 13, 2026 14:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants