Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion litellm/litellm_core_utils/exception_mapping_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2308,7 +2308,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"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Provider-specific dispatch in core

Adding bedrock_mantle here places provider-specific behavior outside the provider layer, fragmenting its error handling and increasing the maintenance cost when the Mantle adapter evolves.

Rule Used: What: Avoid writing provider-specific code outside... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

_map_bedrock_exception(
model=model,
original_exception=mappable_exception,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,3 +680,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
Loading