Skip to content

Reject invalid Amazon Bedrock model IDs in the Anthropic provider#69404

Merged
guan404ming merged 1 commit into
apache:mainfrom
guan404ming:fix-anthropic-bedrock-model-id
Jul 6, 2026
Merged

Reject invalid Amazon Bedrock model IDs in the Anthropic provider#69404
guan404ming merged 1 commit into
apache:mainfrom
guan404ming:fix-anthropic-bedrock-model-id

Conversation

@guan404ming

Copy link
Copy Markdown
Member

Why

The default model claude-opus-4-8 is a bare first-party ID that Amazon Bedrock rejects, so a Bedrock connection without an overridden model failed with an opaque 400.

Reference: https://platform.claude.com/docs/en/build-with-claude/claude-on-amazon-bedrock-legacy

How

  • Add _resolve_model to validate the resolved model on the bedrock platform, raising AnthropicError with the correct prefixed-ID guidance.
  • Route create_message through the validator; leave Vertex, Foundry, and first-party unchanged.
  • Cover with tests for Bedrock rejection, prefixed-ID acceptance, and Vertex passthrough.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    Claude Code with opus 4.8

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@guan404ming guan404ming marked this pull request as ready for review July 5, 2026 13:38
@Vamsi-klu

Copy link
Copy Markdown
Contributor

Could the Bedrock check be a stricter prefix/format check instead of "anthropic." not in resolved? Any string containing that substring passes, even if it is not a valid Bedrock model ID. Checking known prefixes like global.anthropic. / region prefixes, or at least resolved.startswith(...), would better match the intended guard.


Drafted-by: Codex (GPT-5); reviewed by @Vamsi-klu before posting

@guan404ming guan404ming force-pushed the fix-anthropic-bedrock-model-id branch from 345e4c1 to 4852337 Compare July 6, 2026 06:52
@guan404ming guan404ming force-pushed the fix-anthropic-bedrock-model-id branch from 4852337 to 8fc85ec Compare July 6, 2026 06:56
@guan404ming

Copy link
Copy Markdown
Member Author

Nice suggestion, just fixed!

@guan404ming

Copy link
Copy Markdown
Member Author

Thanks @vincbeck !

@guan404ming guan404ming merged commit db6c95a into apache:main Jul 6, 2026
78 checks passed
@guan404ming guan404ming deleted the fix-anthropic-bedrock-model-id branch July 6, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants