diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.py index 1d880616cdf..0c15692d79e 100644 --- a/litellm/llms/custom_httpx/llm_http_handler.py +++ b/litellm/llms/custom_httpx/llm_http_handler.py @@ -6000,7 +6000,7 @@ class BaseLLMHTTPHandler: if error_headers is None and error_response: error_headers = getattr(error_response, "headers", None) if error_response and hasattr(error_response, "text"): - error_text = getattr(error_response, "text", error_text) + error_text = getattr(error_response, "text", None) or error_text if error_headers: error_headers = dict(error_headers) else: diff --git a/tests/unit/test_model_block_unblock.py b/tests/unit/test_model_block_unblock.py index da63ed4a95a..7045cd77439 100644 --- a/tests/unit/test_model_block_unblock.py +++ b/tests/unit/test_model_block_unblock.py @@ -195,7 +195,7 @@ async def test_route_request_returns_403_when_model_is_fully_blocked(monkeypatch with pytest.raises(litellm.PermissionDeniedError) as exc_info: await route_request( - data={"model": "gpt-4o"}, + data={"model": "gpt-4o", "data_source_config": {"type": "custom"}, "testing_criteria": []}, llm_router=router, user_model=None, route_type="acreate_eval", diff --git a/tests/unit/test_video_generation.py b/tests/unit/test_video_generation.py index 5c1d0bfa884..a1e5a335fd5 100644 --- a/tests/unit/test_video_generation.py +++ b/tests/unit/test_video_generation.py @@ -1109,6 +1109,7 @@ def test_video_content_handler_passes_variant_to_url(): mock_client = MagicMock(spec=HTTPHandler) mock_response = MagicMock() mock_response.content = b"thumbnail-bytes" + mock_response.status_code = 200 mock_client.get.return_value = mock_response with patch( @@ -1154,6 +1155,7 @@ def test_video_content_handler_uses_get_for_openai(): mock_client = MagicMock(spec=HTTPHandler) mock_response = MagicMock() mock_response.content = b"mp4-bytes" + mock_response.status_code = 200 mock_client.get.return_value = mock_response # Patch _get_httpx_client to ensure no real HTTP client is created