Map every `MistralError` from the Mistral SDK to `ModelHTTPError` or `ModelAPIError`
Found while auditing how each provider adapter maps SDK errors (related: #8722).
MistralModel's _map_api_errors caught only SDKError, but the Mistral SDK raises two other MistralError subclasses from the same calls:
HTTPValidationErrorfor a 422, on bothrequestandrequest_streamResponseValidationErrorfor a 200 body it can't parse
Both escaped Agent.run() raw, so except ModelHTTPError / except ModelAPIError missed them and FallbackModel's default fallback_on=(ModelAPIError,) never fell back. The mapper now catches the SDK base class: a 4xx/5xx still becomes ModelHTTPError with the real status, body and headers, and anything else becomes ModelAPIError, both chained from the SDK error.
New public surface: none.
Verification
tests/models/test_mistral.py::test_model_validation_error_raises_model_http_error[request]and[stream]: a 422 surfaces asModelHTTPError(422)with body and headers,__cause__isHTTPValidationError.tests/models/test_mistral.py::test_model_unparseable_response_body_raises_model_api_error: a blank 200 body surfaces asModelAPIError,__cause__isResponseValidationError.- All three fail with the raw SDK error when the fix is reverted.
What changes for existing users: a Mistral 422 or unparseable 200 now raises ModelHTTPError / ModelAPIError instead of the raw SDK exception. Other errors are unaffected.
Not changed here: connection errors and timeouts still escape as raw httpx2 errors from MistralModel, as they do from several other adapters; that is a separate cross-provider fix.
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