BerriAI/litellm · error · HTTPException
File size too large. Maximum size is 5MB.
Error message
File size too large. Maximum size is 5MB.
What it means
Size guard in the logo upload endpoint: the fully read upload body exceeds the 5MB cap. Large logos bloat config storage and slow the unauthenticated image-serving path, so oversized files are rejected after the size check rather than stored.
Source
Thrown at litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py:1570
Accepts image files (PNG, JPG, JPEG, SVG) and stores them for use in the UI.
"""
import os
from pathlib import Path
# Validate file type
allowed_extensions: Final = {".png", ".jpg", ".jpeg", ".svg"}
file_extension: Final = Path(file.filename or "").suffix.lower()
if file_extension not in allowed_extensions:
raise HTTPException(
status_code=400,
detail=f"Invalid file type. Allowed types: {', '.join(allowed_extensions)}",
)
# Validate file size (max 5MB)
file_content: Final = await file.read()
if len(file_content) > 5 * 1024 * 1024: # 5MB
raise HTTPException(status_code=400, detail="File size too large. Maximum size is 5MB.")
# Create uploads directory if it doesn't exist
current_dir: Final = os.path.dirname(os.path.abspath(__file__))
upload_dir: Final = os.path.join(current_dir, "..", "uploads")
os.makedirs(upload_dir, exist_ok=True)
# Generate unique filename
from litellm._uuid import uuid
unique_filename: Final = f"logo_{uuid.uuid4().hex}{file_extension}"
file_path: Final = os.path.join(upload_dir, unique_filename)
# Save the file
with open(file_path, "wb") as buffer:
buffer.write(file_content)
return {
"message": "Logo uploaded successfully",View on GitHub (pinned to 77b7c6c40c)
Solutions
- Reduce the file to 5MB or smaller before uploading.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py:1570 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/b448570428587315.
Report an issue: GitHub.