{"record":{"id":"401084a67e15053a","repo":"BerriAI/litellm","slug":"uploaded-file-is-empty","errorCode":null,"errorMessage":"Uploaded file is empty","messagePattern":"Uploaded file is empty","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/ocr_endpoints/endpoints.py","lineNumber":76,"sourceCode":"            f\"Failed to parse multipart form data: {e}. \"\n            \"When using curl with --form/-F, do NOT set the Content-Type header \"\n            \"manually — curl will set it automatically with the required boundary.\"\n        )\n\n    uploaded_file = form.get(\"file\")\n    # request.form() may return either a FastAPI or Starlette UploadFile\n    # depending on middleware; check both via isinstance (FastAPI's UploadFile\n    # is a subclass of Starlette's) and fall back to duck-type check.\n    if uploaded_file is None or (not isinstance(uploaded_file, UploadFile) and not hasattr(uploaded_file, \"read\")):\n        raise ValueError(\"Multipart OCR request must include a 'file' field with the document to process\")\n\n    uploaded_file = cast(UploadFile, uploaded_file)\n\n    # Seek to start in case the file was already partially read by middleware\n    await uploaded_file.seek(0)\n    file_content: Final = await uploaded_file.read()\n    if not file_content:\n        raise ValueError(\"Uploaded file is empty\")\n\n    document: Final = _build_document_from_upload(\n        file_content=file_content,\n        filename=uploaded_file.filename,\n        content_type=uploaded_file.content_type,\n    )\n\n    data: Final[dict[str, Any]] = {\"document\": document}\n\n    for field_name, field_value in form.items():\n        if field_name in (\"file\", \"document\"):\n            continue\n        # Try to parse JSON values (e.g. pages=[0,1,2])\n        if isinstance(field_value, str):\n            try:\n                data[field_name] = json.loads(field_value)\n            except (json.JSONDecodeError, ValueError):\n                data[field_name] = field_value","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/ocr_endpoints/endpoints.py#L58-L94","documentation":"ValueError raised in OCR multipart parsing: a 'file' field was provided but the uploaded file has zero size (empty UploadFile), so there is no document content to process. The client must attach a non-empty file.","triggerScenarios":"Thrown at litellm/proxy/ocr_endpoints/endpoints.py:76 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Upload a non-empty file."],"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"}