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(proxy): validate enforced_file_expires_after keys before access
Ryan Crabbed6ad312a4c2a
diff --git a/litellm/proxy/openai_files_endpoints/files_endpoints.py b/litellm/proxy/openai_files_endpoints/files_endpoints.pyindex a641fb1c69f..386ab2bf044 100644--- a/litellm/proxy/openai_files_endpoints/files_endpoints.py+++ b/litellm/proxy/openai_files_endpoints/files_endpoints.py@@ -458,11 +458,22 @@ async def create_file( # noqa: PLR0915team_metadata = user_api_key_dict.team_metadata or {}enforced_file_expiry = team_metadata.get("enforced_file_expires_after")if enforced_file_expiry is not None:+ if "anchor" not in enforced_file_expiry or "seconds" not in enforced_file_expiry:+ raise HTTPException(+ status_code=400,+ detail={+ "error": "enforced_file_expires_after must contain 'anchor' and 'seconds' keys",+ },+ )expires_after = FileExpiresAfter(anchor=enforced_file_expiry["anchor"],seconds=enforced_file_expiry["seconds"],)+ verbose_proxy_logger.info(+ "create_file expires_after: %s", expires_after+ )+_create_file_request = CreateFileRequest(file=file_data,purpose=cast(CREATE_FILE_REQUESTS_PURPOSE, purpose),