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
fix: handle explicit outputInfo: null in Vertex AI batch response (#34473)
yucheng-berri61d32c9aac79
diff --git a/litellm/llms/vertex_ai/batches/transformation.py b/litellm/llms/vertex_ai/batches/transformation.pyindex 6bbe8f75701..df903ba7ef0 100644--- a/litellm/llms/vertex_ai/batches/transformation.py+++ b/litellm/llms/vertex_ai/batches/transformation.py@@ -123,7 +123,8 @@ class VertexAIBatchTransformation:Gets the output file id from the Vertex AI Batch response"""- output_file_id: str = response.get("outputInfo", OutputInfo()).get("gcsOutputDirectory", "")+ output_info = response.get("outputInfo") or OutputInfo()+ output_file_id: str = output_info.get("gcsOutputDirectory", "")if output_file_id:output_file_id = output_file_id.rstrip("/") + "/predictions.jsonl"if output_file_id and output_file_id != "/predictions.jsonl":diff --git a/tests/test_litellm/llms/vertex_ai/batches/test_transformation.py b/tests/test_litellm/llms/vertex_ai/batches/test_transformation.pyindex 71da1d39876..1b37ade6b30 100644--- a/tests/test_litellm/llms/vertex_ai/batches/test_transformation.py+++ b/tests/test_litellm/llms/vertex_ai/batches/test_transformation.py@@ -226,6 +226,18 @@ def test_get_output_file_id_empty_output_info_falls_through_to_output_config():assert T._get_output_file_id_from_vertex_ai_batch_response(resp) == "gs://b/cfg/predictions.jsonl"+def test_get_output_file_id_output_info_explicit_none_falls_through_to_output_config():+ resp = {+ "outputInfo": None,+ "outputConfig": {"gcsDestination": {"outputUriPrefix": "gs://b/cfg"}},+ }+ assert T._get_output_file_id_from_vertex_ai_batch_response(resp) == "gs://b/cfg/predictions.jsonl"+++def test_get_output_file_id_output_info_explicit_none_and_no_output_config():+ assert T._get_output_file_id_from_vertex_ai_batch_response({"outputInfo": None}) == ""++def test_get_output_file_id_no_output_info_and_no_output_config():assert T._get_output_file_id_from_vertex_ai_batch_response({}) == ""