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(s3): replace colons in generated log filenames (#40452)
mubashir1osmanib4ccb5b74742
diff --git a/litellm/integrations/s3.py b/litellm/integrations/s3.pyindex 796784fb993..54ec876fd0d 100644--- a/litellm/integrations/s3.py+++ b/litellm/integrations/s3.py@@ -277,7 +277,7 @@ def get_s3_object_key(start_time: datetime,s3_file_name: str,) -> str:- sanitized_s3_file_name: Final = s3_file_name.replace("/", "_")+ sanitized_s3_file_name: Final = s3_file_name.replace("/", "_").replace(":", "_")configured_prefix: Final = (s3_path.rstrip("/") + "/" if s3_path else "") + prefixdate_segment: Final = start_time.strftime("%Y-%m-%d") + "/"# we need the s3 key to include the time, so we log cache hits toodiff --git a/tests/test_litellm/integrations/test_s3_v2.py b/tests/test_litellm/integrations/test_s3_v2.pyindex 52fbbe40b0e..a9d13038180 100644--- a/tests/test_litellm/integrations/test_s3_v2.py+++ b/tests/test_litellm/integrations/test_s3_v2.py@@ -1273,9 +1273,7 @@ async def test_combined_prefix_reflects_in_s3_object_key():assert "myteam/apikey/" in key, f"Expected both prefixes in key: {key}"-def test_s3_object_key_sanitizes_slashes_in_file_name():- """Response ids containing slashes (e.g. bedrock batch job ARNs) must not- create nested S3 folders; only path/prefix/date slashes are separators."""+def test_s3_object_key_sanitizes_slashes_and_colons_in_file_name():from litellm.integrations.s3 import get_s3_object_keystart_time = datetime(2026, 2, 11, 0, 35, 18, 391582)@@ -1290,10 +1288,32 @@ def test_s3_object_key_sanitizes_slashes_in_file_name():assert key == ("LiteLLMAPPLogs/myteam/2026-02-11/"- "time-00-35-18-391582_arn:aws:bedrock:us-east-1:123456789012:model-invocation-job_gl18r6skk9yy.json"+ "time-00-35-18-391582_arn_aws_bedrock_us-east-1_123456789012_model-invocation-job_gl18r6skk9yy.json")+ "response_id",+ [+ "s3://example-batch-bucket/litellm-bedrock-files/input.jsonl",+ "gs://example-batch-bucket/litellm-vertex-files/input.jsonl",+ ],+)+def test_s3_object_key_has_no_colon_for_cloud_uri_file_ids(response_id: str):+ from litellm.integrations.s3 import get_s3_object_key++ key = get_s3_object_key(+ s3_path="",+ prefix="",+ start_time=datetime(2026, 9, 7, 4, 51, 6, 685889),+ s3_file_name=f"time-04-51-06-685889_{response_id}",+ )++ filename = key.rsplit("/", 1)[-1]+ assert ":" not in filename+ assert filename.endswith("_input.jsonl.json")++def test_create_s3_batch_logging_element_flat_key_for_arn_response_id():"""End-to-end through the s3_v2 element builder: an ARN response id mustyield a flat file directly under the date segment."""