Skip to content

chore: improve expired Bedrock credential errors - #28992

Merged
celia-oai merged 4 commits into
mainfrom
codex/bedrock-expired-signature-error
Jun 23, 2026
Merged

chore: improve expired Bedrock credential errors#28992
celia-oai merged 4 commits into
mainfrom
codex/bedrock-expired-signature-error

Conversation

@celia-oai

@celia-oai celia-oai commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Why

Amazon Bedrock returns a 401 Unauthorized response containing Signature expired: when an AWS credential, including a short-lived AWS_BEARER_TOKEN_BEDROCK, has expired. Codex currently surfaces that response as a generic unexpected status error, which does not explain how to recover.

Environment-provided bearer tokens cannot be refreshed automatically, so the error should direct users to refresh their AWS credentials or replace or remove the environment token and restart Codex. This classification belongs to the Amazon Bedrock provider so similar responses from other providers retain their existing behavior.

What changed

  • Add a synchronous ModelProvider::map_api_error hook that defaults to the existing provider-neutral API error mapping, and route model request, stream, WebSocket, and terminal unauthorized errors through the active provider.
  • Override the hook for Amazon Bedrock. After preserving the structured status, body, URL, and request metadata, recognize 401 responses containing Signature expired: and attach actionable credential guidance.
  • Keep codex-protocol provider-neutral by representing the guidance as an optional user_message. Error rendering prefers this message while continuing to append the URL, request ID, Cloudflare ray, and authorization diagnostics.
  • Add model-provider coverage for expired signatures and negative cases, core coverage for provider dispatch after unauthorized recovery, and a TUI snapshot for the rendered error.

Testing

Tested with a real request with expired bedrock key:
Screenshot 2026-06-22 at 3 56 51 PM

@celia-oai
celia-oai force-pushed the codex/bedrock-expired-signature-error branch from 1e6e48d to 481758a Compare June 18, 2026 22:41
@celia-oai celia-oai changed the title [codex] Improve expired Bedrock credential errors feat: improve expired Bedrock credential errors Jun 22, 2026
@celia-oai celia-oai changed the title feat: improve expired Bedrock credential errors chore: improve expired Bedrock credential errors Jun 22, 2026
@celia-oai
celia-oai force-pushed the codex/bedrock-expired-signature-error branch from 302648c to e7e3628 Compare June 22, 2026 22:46
@celia-oai
celia-oai requested a review from pakrym-oai June 22, 2026 22:57
@celia-oai
celia-oai marked this pull request as ready for review June 22, 2026 22:57
@celia-oai
celia-oai requested a review from a team as a code owner June 22, 2026 22:57
Comment thread codex-rs/protocol/src/error.rs Outdated
Comment thread codex-rs/protocol/src/error.rs Outdated
@celia-oai
celia-oai force-pushed the codex/bedrock-expired-signature-error branch from 4d02a6c to 8044575 Compare June 23, 2026 00:38
@celia-oai
celia-oai enabled auto-merge (squash) June 23, 2026 00:40
@celia-oai
celia-oai merged commit e65e480 into main Jun 23, 2026
31 checks passed
@celia-oai
celia-oai deleted the codex/bedrock-expired-signature-error branch June 23, 2026 00:53
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants