Raise `BedrockEmbeddingModel` errors as `ModelHTTPError`/`ModelAPIError` instead of an `ExceptionGroup`, and map botocore transport errors
Related: #8722. I found this while auditing how each provider adapter maps its errors.
A failed BedrockEmbeddingModel request didn't surface as the ModelHTTPError or ModelAPIError that BedrockConverseModel raises for the same failure:
- Every error escaped wrapped in an
ExceptionGroupfrom the anyio task group in_embed_concurrent, even for a single input. Soexcept ModelHTTPError/except ModelAPIErrornever matched: a throttledembed_query()raisedExceptionGroup([ModelHTTPError(429)]). - botocore transport failures (
ReadTimeoutError,EndpointConnectionError) weren't mapped at all. OnlyClientErrorwas.
Changes:
_embed_concurrentnow runs its requests through the existing_utils.gather, which cancels queued requests on the first failure. In-flight requests run in threads that can't be cancelled, so a throttle or validation error usually fails several of them. When that happens, the first model error is raised on its own._invoke_modelmapsHTTPClientErrorand botocore'sConnectionErrortoModelAPIError, using the same clause asmodels/bedrock.py's_map_api_errors.
New public surface: none.
What changes for existing users: A failed Bedrock embedding request now raises ModelHTTPError / ModelAPIError directly instead of an ExceptionGroup holding one of them. Code that caught the group with except* ModelHTTPError keeps working; code that caught it with except ExceptionGroup does not. Transport errors raise ModelAPIError instead of the raw botocore exception.
Verification
tests/test_embeddings.py::TestBedrock::test_client_error_with_status_codeand::test_client_error_without_status_codepreviously asserted theExceptionGroupwrapping; they now assert the bare exception.tests/test_embeddings.py::TestBedrock::test_client_error_on_every_concurrent_request: a 429 on every one of 3 concurrent requests raises oneModelHTTPError.tests/test_embeddings.py::TestBedrock::test_transport_errorcovers[read-timeout]and[endpoint-connection].- Reverting the source change makes all 5 tests fail.
A 200 with a non-JSON body still raises json.JSONDecodeError. That's the same class of bug as #8843, and I've left it for follow-up alongside #8846.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
- PR title is fit for the release changelog.
š¤ Generated with Claude Code