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(gemini): cover decoded delete file names

user87849b74b9b7
diff --git a/tests/test_litellm/llms/gemini/files/test_gemini_files_transformation.py b/tests/test_litellm/llms/gemini/files/test_gemini_files_transformation.py
index 334c691fdba..88010d01459 100644
--- a/tests/test_litellm/llms/gemini/files/test_gemini_files_transformation.py
+++ b/tests/test_litellm/llms/gemini/files/test_gemini_files_transformation.py
@@ -398,3 +398,16 @@ class TestGoogleAIStudioFilesTransformation:
optional_params={},
litellm_params=litellm_params,
)
+
+ def test_transform_delete_file_request_rejects_deeply_encoded_traversal_url(self):
+ litellm_params = {
+ "api_key": "test-api-key",
+ "api_base": "https://generativelanguage.googleapis.com",
+ }
+
+ with pytest.raises(ValueError, match="Invalid Gemini file name"):
+ self.handler.transform_delete_file_request(
+ file_id="https://generativelanguage.googleapis.com/v1beta/files/..%2525252Fsecrets",
+ optional_params={},
+ litellm_params=litellm_params,
+ )