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(managed_files): log sanitized validation errors when skipping rows
mateo-berri1b6f3cebf1a4
diff --git a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py b/enterprise/litellm_enterprise/proxy/hooks/managed_files.pyindex 2349b618a28..688ffb35ff7 100644--- a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py+++ b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py@@ -7,6 +7,7 @@ from types import MappingProxyTypefrom typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Union, castfrom fastapi import HTTPException+from pydantic import ValidationErrorimport litellmfrom litellm import Router, verbose_logger@@ -80,9 +81,15 @@ def _parse_managed_file_object(return Nonetry:return OpenAIFileObject.model_validate(raw_file_object)+ except ValidationError as e:+ verbose_logger.warning(+ f"Failed to parse managed file object {unified_file_id}: "+ f"{e.errors(include_input=False, include_url=False, include_context=False)}"+ )+ return Noneexcept Exception as e:verbose_logger.warning(- f"Failed to parse managed file object {unified_file_id}: {e}"+ f"Failed to parse managed file object {unified_file_id}: {type(e).__name__}")return Nonediff --git a/tests/test_litellm/enterprise/proxy/test_managed_files_hook.py b/tests/test_litellm/enterprise/proxy/test_managed_files_hook.pyindex 4da6de6353f..6397e0be247 100644--- a/tests/test_litellm/enterprise/proxy/test_managed_files_hook.py+++ b/tests/test_litellm/enterprise/proxy/test_managed_files_hook.py@@ -6,6 +6,7 @@ async_post_call_success_hook when processing completed batch responses."""import json+import loggingimport pytestfrom typing import Optional@@ -154,6 +155,24 @@ async def test_get_user_created_file_ids_skips_rows_without_file_object():assert [file.id for file in files] == ["file-output-abc"]+async def test_parse_managed_file_object_warning_omits_rejected_values(caplog):+ from litellm_enterprise.proxy.hooks.managed_files import (+ _parse_managed_file_object,+ )++ with caplog.at_level(logging.WARNING):+ parsed = _parse_managed_file_object(+ {"id": "file-corrupt", "object": "file", "filename": "confidential.jsonl"},+ "unified-corrupt",+ )++ assert parsed is None+ assert "unified-corrupt" in caplog.text+ assert "bytes" in caplog.text+ assert "confidential.jsonl" not in caplog.text++@pytest.mark.asyncioasync def test_get_user_created_file_ids_skips_unparseable_rows():managed_files = _make_managed_files_instance()