BerriAI/litellm · error · HTTPException

Invalid file type. Allowed types: {', '.join(allowed_extensi

Error message

Invalid file type. Allowed types: {', '.join(allowed_extensions)}

What it means

File-type guard in the logo upload endpoint: the uploaded file's extension is not one of .png/.jpg/.jpeg/.svg. The logo is stored and served by the admin UI, so arbitrary file types are rejected up front; renaming a file to a listed extension does not convert it, so content should genuinely be an image of an allowed type.

Source

Thrown at litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py:1562

@router.post(
    "/upload/logo",
    tags=["UI Theme Settings"],
    dependencies=[Depends(user_api_key_auth)],
)
async def upload_logo(file: UploadFile = File(...)):
    """
    Upload a custom logo for the admin UI.
    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}"

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Upload a file with one of the listed allowed extensions.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py:1562 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/06ea0bee844794b5. Report an issue: GitHub.