fix(responses): preserve Bedrock Mantle validation status (#36580)

This commit is contained in:
Ruiming Zhao 2026-08-21 10:21:30 -07:00 committed by GitHub
parent f9a8c96b82
commit c1662258df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -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,

View file

@ -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