From 12ecac6f4673a73f711ec72b6bf96e40f0b83570 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 2 May 2026 07:00:55 +0000 Subject: [PATCH] test vertex file content logging forwarding Co-authored-by: Sameer Kankute --- .../llms/vertex_ai/files/transformation.py | 2 -- .../test_vertex_ai_files_transformation.py | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/litellm/llms/vertex_ai/files/transformation.py b/litellm/llms/vertex_ai/files/transformation.py index b7509269f42..29c2a72c005 100644 --- a/litellm/llms/vertex_ai/files/transformation.py +++ b/litellm/llms/vertex_ai/files/transformation.py @@ -582,8 +582,6 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig): ) if transformed_content != content: # Create a new response with transformed content and updated Content-Length - import httpx - # Update headers with correct Content-Length new_headers = dict(raw_response.headers) new_headers["content-length"] = str(len(transformed_content)) diff --git a/tests/test_litellm/llms/vertex_ai/files/test_vertex_ai_files_transformation.py b/tests/test_litellm/llms/vertex_ai/files/test_vertex_ai_files_transformation.py index 239621f4153..c8d3fb384c8 100644 --- a/tests/test_litellm/llms/vertex_ai/files/test_vertex_ai_files_transformation.py +++ b/tests/test_litellm/llms/vertex_ai/files/test_vertex_ai_files_transformation.py @@ -149,6 +149,39 @@ class TestTransformFileContent: assert isinstance(result, HttpxBinaryResponseContent) assert result.response.content == b'{"line": 1}\n{"line": 2}\n' + def test_should_forward_logging_obj_to_batch_output_transformer( + self, config, monkeypatch + ): + raw_response = httpx.Response( + status_code=200, + content=b'{"line": 1}\n', + headers={"content-type": "application/octet-stream"}, + request=httpx.Request("GET", "https://example.com"), + ) + logging_obj = MagicMock() + captured = {} + + def mock_try_transform_vertex_batch_output_to_openai(content, logging_obj=None): + captured["content"] = content + captured["logging_obj"] = logging_obj + return content + + monkeypatch.setattr( + config, + "_try_transform_vertex_batch_output_to_openai", + mock_try_transform_vertex_batch_output_to_openai, + ) + + result = config.transform_file_content_response( + raw_response=raw_response, + logging_obj=logging_obj, + litellm_params={}, + ) + + assert captured["content"] == raw_response.content + assert captured["logging_obj"] is logging_obj + assert result.response is raw_response + class TestTransformDeleteFile: def test_should_build_correct_gcs_delete_url(self, config):