Repository navigation
fix(bedrock): answer 401 instead of 500 when AWS SSO or profile credentials are unusable - #53362
Merged
Merged
Conversation
Contributor
Author
Contributor
Contributor
[Medium impact] The reviewed changes appear safe to merge, with no new actionable findings.
|
…credential errors by type in tests
Contributor
Author
…uth_error # Conflicts: # tests/unit/rust_bridge/host/routes/test_messages.py
Contributor
Author
Contributor
Author
…opening a connection
Contributor
Author
|
bugbot run |
…annot name a retryable 500
…tial failures Rust cannot name
Contributor
Author
Contributor
Author
|
bugbot run |
Merged
4 of 6 tasks
…uth_error # Conflicts: # tests/unit/llms/bedrock_mantle/test_bedrock_mantle_transformation.py
Contributor
Author
Contributor
Author
|
bugbot run |
Contributor
Author
Contributor
Author
Contributor
Author
|
bugbot run |
Contributor
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit ff9ad03. Configure here.
Contributor
Author
ryan-crabbe-berri
enabled auto-merge (squash)
November 23, 2026 20:37
mateo-berri
approved these changes
Nov 23, 2026
3 of 6 tasks
narmstrong-berri
added a commit
that referenced
this pull request
Nov 24, 2026
…our (#54223) Main's rust-wheel job fails 10 tests in tests/test_litellm_rust/messages, each pinned to behaviour a later PR changed on purpose. The stub check failed first until #53922, so the pytest step never reported them. Credential failures on Bedrock invoke and Mantle now answer a 401 AuthenticationError with the botocore error as its context (#53362). A 200 Bedrock stream whose body is JSON answers BedrockError 502 (#53482). A cut Bedrock stream drops the message_start output placeholder and re-counts the streamed text (#53394). Logging copies the resolved provider into litellm_params before callbacks run (#52709)
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.
Handwritten 1-3 sentence description
When I call Bedrock or Bedrock Mantle with an expired AWS SSO login or a missing profile, the request fails while the gateway is signing it with AWS credentials. That used to come back as a 500 that clients keep retrying, and now it comes back as a 401 that says the login is the problem.
Details
TLDR
/v1/messages,/v1/responsesand embeddings.Intentional product change: an expired SSO login or a missing AWS profile now answers 401 (403 when
aws loginlacks permission). Like any other provider's 401, it is no longer retried and the router cools that deployment down for 5 seconds, unless the bad credential came from the caller's own AWS fields, which #53431 keeps off the shared deployment. SDK callers oflitellm.anthropic.messageson Bedrock used to get the raw botocore error there and now getlitellm.AuthenticationError, with the botocore error kept as its context.User Flow
Before: a developer whose AWS SSO session expired gets a 500 that looks like a LiteLLM bug, so their client keeps retrying
aws_profile_namepointing at an SSO profile whose token has expired/v1/messages,/v1/responses,/v1/embeddings)litellm.APIConnectionError: Error when retrieving token from sso: Token has expired and refresh failedAfter: the same request answers 401, so the client stops retrying and the developer knows to run
aws sso loginauthentication_errorwith the same botocore message about the expired tokenRelevant issues
Fixes #52453
Pre-Submission checklist
Screenshots / Proof of Fix
Shared setup. Both legs ran the same way from a clean copy of each commit, with two workers and one dedicated Redis. A test
HOMEholds three broken AWS profiles (ansso_sessionprofile whose cached token expired in 2020, a legacy SSO profile with an expired token, and a profile name that does not exist) next to a real working SSO profile. Each broken call waits 6 seconds so the router's 5 second cooldown from the previous 401 does not mask the next endpoint's answer.Proxy command, config, and client script
$QA_HOME/.aws/configadds these profiles (the expired token cache files sit in$QA_HOME/.aws/sso/cache,expiresAt: 2020-01-01T00:00:00Z)Each case is one curl per endpoint, for example
Before (c3c6f71)
Every endpoint answers 500 for every broken profile. The working profile answers 200 everywhere.
After (8c933d5)
Every broken profile answers 401 on every endpoint, with botocore's own message. The working profile's SSO session had expired by this run, so it also answers 401 here (the first call, then 429 while that deployment cools down, since
bedrock-goodcalls skip the 6 second gap).The happy path was checked at e5dbf4a, before the real SSO session ran out, and every endpoint still answered 200 with the fix in place. The commits after it only touch the error path (Mantle's credential errors, a merge of main, and tests). The Mantle outage changes at d939f12 and 92cbd08 only affect the credential source outage path, which the guard tests below cover.
The tip ff9ad03 adds two things on top of 92cbd08. It merges main (including #53431), and it keeps a credential outage on the
bedrock/mantle/.../v1/messagesroute retryable, which the new guard test covers. Neither changes the cases shown above. The touched unit tests pass at the tip apart from tests that also fail on main./v1/messageson every Bedrock route, before (dd86656, the merge base) and after (ff9ad03)Same rig, with
bedrock/invoke/...,bedrock/mantle/...andbedrock_mantle/...deployments for each broken profile. The outage rows use deployments with no profile, an emptyAWS_CONFIG_FILE, andAWS_CONTAINER_CREDENTIALS_FULL_URIpointed at a local server that answers 503, so the only credential source is down.Config for this run
Before (dd86656)
After (ff9ad03)
Credential source outage, before (dd86656)
Credential source outage, after (ff9ad03), every row still a retryable 500
Bedrock Mantle
Same rig with these deployments,
bedrock_mantle/openai.gpt-6-solfor chat and Responses andbedrock_mantle/anthropic.claude-sonnet-5-5for/v1/messages, each pointed atmissing-profileand atexpired-sso,aws_region_name: us-east-1.Before (c3c6f71)
After (92cbd08)
A working Mantle call was not run, because the only SSO session on this machine had expired by then.
Tests
aws loginrefresh required, partial keys, missing profile) answers 401 on bedrock and bedrock_mantleaws loginwithout permission answers 403/v1/messageson the Rust path with a logged-out SSO profile answers 401/v1/messageson the Rust path)bedrock/mantle/.../v1/messagesroute stays retryable/v1/messageson Mantle with an SSO profile that has no usable token answers 401/v1/messageson Mantle with no usable credentials answers 401Type
🐛 Bug Fix
Caveats (if any)
Medium
/v1/messages, a credential failure Rust cannot name reruns Python signing inlineLow
CredentialRetrievalErrorstays a 500 on purposecredential_processhelper whose session expired raises it too, so those users still see a 500/v1/messagesoutage guard test runs an in-process HTTP server on 127.0.0.1, as other tests in that file doFinal Attestation