Skip to content

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]

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.py
index 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 = 10
def _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 URL
return 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.py
index 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_response
mock_get_response.status_code = 200
mock_get_response.raise_for_status.return_value = None
+ mock_get_response.is_redirect = False
mock_get.return_value = mock_get_response
retrieved_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_response
mock_get_response.status_code = 200
mock_get_response.raise_for_status.return_value = None
+ mock_get_response.is_redirect = False
mock_get.return_value = mock_get_response
list_response = await litellm.alist_batches(