Repository navigation
fix(gateway): report a Bedrock API key that is not valid as rejected - #235
Merged
Merged
Conversation
Checking a Bedrock upstream took any AccessDeniedException from the model
listing to mean the credential works but may not list models. AWS answers
a Bedrock API key that is not valid with AccessDeniedException too
("Authentication failed: Please make sure your API Key is valid.",
"Invalid API Key format: ..."), so a mistyped key passed the check and the
background model fetch said the credential works.
Only an AccessDeniedException whose message says the identity "is not
authorized" (IAM's "User: arn:... is not authorized to perform: ...") now
counts as missing list permission; any other one is a rejected key. AWS's
message is only inspected, never passed on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
fylorn
added a commit
that referenced
this pull request
Sep 29, 2026
Patch release for #235. - Bump the workspace version to 0.55.2 - release-notes/0.55.2.md The control-plane protocol (28) and the request store schema (22) are unchanged. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
"Check connection" on a Bedrock upstream, and the background model fetch, run
probe_bedrock. It lists the region's models and took anyAccessDeniedExceptionto mean the credential works but lacksbedrock:ListFoundationModels.AWS answers an invalid Bedrock API key with
AccessDeniedExceptionas well. Asking the control plane and the runtime with fabricated keys gives:{"Message":"Invalid API Key format: Must start with pre-defined prefix"}(orDelimiter ':' not found){"Message":"Authentication failed: Please make sure your API Key is valid."}Both return HTTP 403 with
x-amzn-errortype: AccessDeniedException. So a mistyped key passed the check with "The credential works, and it has no permission to list models", and the model fetch logged the same.What changes
An
AccessDeniedExceptioncounts as missing list permission only when AWS's message says the identity "is not authorized", which is IAM's own denial:User: arn:… is not authorized to perform: bedrock:ListFoundationModels …(identifiedinprobe.rs). Any other one is a rejected key (gw.probe.key_rejected). AWS's message is only inspected and never passed on, since it names the account.No message codes change.
Tests
tw-control/tests/bedrock.rs: a new test sends both real messages above withAccessDeniedException, and the probe fails withgw.probe.key_rejected.gw.probe.bedrock_list_deniedwithout the account ID.cargo fmt --check,cargo clippy --workspace --all-targets -D warningsandcargo test --workspacepass locally.🤖 Generated with Claude Code