From c1662258df4a20c115fc184403de4b9e73535ede Mon Sep 17 00:00:00 2001 From: Ruiming Zhao Date: Fri, 21 Aug 2026 10:21:30 -0700 Subject: [PATCH] fix(responses): preserve Bedrock Mantle validation status (#36580) --- .../exception_mapping_utils.py | 2 +- .../test_exception_mapping_utils.py | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/exception_mapping_utils.py b/litellm/litellm_core_utils/exception_mapping_utils.py index d23466938f2..ee179b582cf 100644 --- a/litellm/litellm_core_utils/exception_mapping_utils.py +++ b/litellm/litellm_core_utils/exception_mapping_utils.py @@ -2315,7 +2315,7 @@ def exception_type( exception_provider=exception_provider, extra_information=extra_information, ) - elif custom_llm_provider == "bedrock": + elif custom_llm_provider in ("bedrock", "bedrock_mantle"): _map_bedrock_exception( model=model, original_exception=mappable_exception, diff --git a/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py b/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py index d5676aaf288..904675d4adc 100644 --- a/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py +++ b/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py @@ -762,3 +762,26 @@ def test_azure_404_with_invalid_request_error_type_maps_to_not_found(): assert excinfo.value.status_code == 404 assert "Response with id 'resp_abc' not found." in excinfo.value.message + + +def test_bedrock_mantle_400_maps_to_bad_request(): + from litellm.llms.base_llm.chat.transformation import BaseLLMException + + original_exception = BaseLLMException( + status_code=400, + message=( + '{"error": {"code": "validation_error", "message": ' + "\"invalid request body: Invalid 'input': value did not match any expected variant\", " + '"type": "invalid_request_error"}}' + ), + ) + + with pytest.raises(litellm.BadRequestError) as excinfo: + exception_type( + model="gpt-5.6-terra", + original_exception=original_exception, + custom_llm_provider="bedrock_mantle", + ) + + assert excinfo.value.status_code == 400 + assert "Invalid 'input'" in excinfo.value.message