{"record":{"id":"b448570428587315","repo":"BerriAI/litellm","slug":"file-size-too-large-maximum-size-is-5mb","errorCode":null,"errorMessage":"File size too large. Maximum size is 5MB.","messagePattern":"File size too large\\. Maximum size is 5MB\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py","lineNumber":1570,"sourceCode":"    Accepts image files (PNG, JPG, JPEG, SVG) and stores them for use in the UI.\n    \"\"\"\n    import os\n    from pathlib import Path\n\n    # Validate file type\n    allowed_extensions: Final = {\".png\", \".jpg\", \".jpeg\", \".svg\"}\n    file_extension: Final = Path(file.filename or \"\").suffix.lower()\n\n    if file_extension not in allowed_extensions:\n        raise HTTPException(\n            status_code=400,\n            detail=f\"Invalid file type. Allowed types: {', '.join(allowed_extensions)}\",\n        )\n\n    # Validate file size (max 5MB)\n    file_content: Final = await file.read()\n    if len(file_content) > 5 * 1024 * 1024:  # 5MB\n        raise HTTPException(status_code=400, detail=\"File size too large. Maximum size is 5MB.\")\n\n    # Create uploads directory if it doesn't exist\n    current_dir: Final = os.path.dirname(os.path.abspath(__file__))\n    upload_dir: Final = os.path.join(current_dir, \"..\", \"uploads\")\n    os.makedirs(upload_dir, exist_ok=True)\n\n    # Generate unique filename\n    from litellm._uuid import uuid\n\n    unique_filename: Final = f\"logo_{uuid.uuid4().hex}{file_extension}\"\n    file_path: Final = os.path.join(upload_dir, unique_filename)\n\n    # Save the file\n    with open(file_path, \"wb\") as buffer:\n        buffer.write(file_content)\n\n    return {\n        \"message\": \"Logo uploaded successfully\",","sourceCodeStart":1552,"sourceCodeEnd":1588,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py#L1552-L1588","documentation":"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.","triggerScenarios":"Thrown at litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py:1570 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the file to 5MB or smaller before uploading."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}