From d2e4e7468503480dc7708e110a4d839ed7c68f87 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Tue, 25 Aug 2026 23:52:30 -0700 Subject: [PATCH] fix(otel): drop the generic BaseLLMException fallback from exception_type The fallback mapped every unbranched provider error by status code on every route, which changed the exception class and HTTP status for those providers and failed four provider test suites in CI. The /v1/messages handler change alone covers the ticket, since the anthropic branch already maps its errors --- .../exception_mapping_utils.py | 12 --------- .../test_exception_mapping_utils.py | 27 ------------------- 2 files changed, 39 deletions(-) diff --git a/litellm/litellm_core_utils/exception_mapping_utils.py b/litellm/litellm_core_utils/exception_mapping_utils.py index b76c97ad2de..4ee726b67de 100644 --- a/litellm/litellm_core_utils/exception_mapping_utils.py +++ b/litellm/litellm_core_utils/exception_mapping_utils.py @@ -2486,18 +2486,6 @@ def exception_type( exception_provider=exception_provider, extra_information=extra_information, ) - from litellm.llms.base_llm.chat.transformation import BaseLLMException - - if custom_llm_provider and isinstance(original_exception, BaseLLMException): - _map_openai_like_exception( - model=model, - original_exception=mappable_exception, - custom_llm_provider=custom_llm_provider, - error_str=error_str, - exception_type=exception_type, - exception_provider=exception_provider, - extra_information=extra_information, - ) if "BadRequestError.__init__() missing 1 required positional argument: 'param'" in str( original_exception ): # deal with edge-case invalid request error bug in openai-python sdk 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 3eb8094f914..6f7ea9da640 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 @@ -1092,30 +1092,3 @@ def test_bedrock_mantle_context_overflow_maps_to_context_window_exceeded(): assert excinfo.value.status_code == 400 assert "prompt is too long: 1055489 tokens > 1050000 maximum" in excinfo.value.message - - -@pytest.mark.parametrize( - "status_code, expected_class", - [(401, litellm.AuthenticationError), (429, litellm.RateLimitError)], -) -def test_a_base_llm_exception_without_a_provider_branch_maps_by_status_code( - status_code, expected_class, quiet_exception_mapping -): - """Regression test for LIT-6164. Native /v1/messages handlers raise raw - BaseLLMException, and providers without an exception_type branch (e.g. - minimax) must keep the upstream status instead of collapsing every failure - into a 500 APIConnectionError once that route maps its exceptions.""" - from litellm.llms.base_llm.chat.transformation import BaseLLMException - - original_exception = BaseLLMException(status_code=status_code, message="upstream rejected the call") - - with pytest.raises(expected_class) as excinfo: - exception_type( - model="MiniMax-M2.5", - original_exception=original_exception, - custom_llm_provider="minimax", - ) - - assert excinfo.value.status_code == status_code - assert excinfo.value.llm_provider == "minimax" - assert "MinimaxException" in excinfo.value.message