The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(vertex_batch): set is_redirect=False on mocked AsyncHTTPHandler responses
Claudedc123d9f12d8
diff --git a/litellm/litellm_core_utils/url_utils.py b/litellm/litellm_core_utils/url_utils.pyindex a65d0892aa2..aabf4e84a3b 100644--- a/litellm/litellm_core_utils/url_utils.py+++ b/litellm/litellm_core_utils/url_utils.py@@ -205,7 +205,7 @@ _MAX_REDIRECTS = 10def _extract_redirect_url(response: Any, request_url: str) -> str:"""Extract and resolve the redirect target from a response's Location header."""location = response.headers.get("location")- if not location:+ if not isinstance(location, str) or not location:raise SSRFError("Redirect response has no Location header")# Resolve relative URLs against the request URLreturn str(httpx.URL(request_url).join(location))diff --git a/tests/batches_tests/test_openai_batches_and_files.py b/tests/batches_tests/test_openai_batches_and_files.pyindex 0aed224c256..3f69aa01f9c 100644--- a/tests/batches_tests/test_openai_batches_and_files.py+++ b/tests/batches_tests/test_openai_batches_and_files.py@@ -558,6 +558,7 @@ async def test_avertex_batch_prediction(monkeypatch):mock_get_response.json.return_value = mock_vertex_batch_responsemock_get_response.status_code = 200mock_get_response.raise_for_status.return_value = None+ mock_get_response.is_redirect = Falsemock_get.return_value = mock_get_responseretrieved_batch = await litellm.aretrieve_batch(@@ -590,6 +591,7 @@ async def test_vertex_list_batches(monkeypatch):mock_get_response.json.return_value = mock_vertex_list_responsemock_get_response.status_code = 200mock_get_response.raise_for_status.return_value = None+ mock_get_response.is_redirect = Falsemock_get.return_value = mock_get_responselist_response = await litellm.alist_batches(