{"record":{"id":"34ceb777c652fd3e","repo":"BerriAI/litellm","slug":"failed-to-parse-multipart-form-data-e-when-usi","errorCode":null,"errorMessage":"Failed to parse multipart form data: {e}. When using curl with --form/-F, do NOT set the Content-Type header manually — curl will set it automatically with the required boundary.","messagePattern":"Failed to parse multipart form data: (.+?)\\. When using curl with --form/-F, do NOT set the Content-Type header manually — curl will set it automatically with the required boundary\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/ocr_endpoints/endpoints.py","lineNumber":57,"sourceCode":"            \"mime_type\": mime_type or \"application/octet-stream\",\n        }\n    )\n\n\nasync def _parse_multipart_form(request: Request) -> dict[str, Any]:\n    \"\"\"\n    Extract OCR data from a multipart form request.\n\n    Uses the cached form if already parsed by auth middleware,\n    otherwise parses the form from the request.\n\n    Returns:\n        A dict with 'document', 'model', and any other OCR params.\n    \"\"\"\n    try:\n        form: Final = await request.form()\n    except Exception as e:\n        raise ValueError(\n            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:","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/ocr_endpoints/endpoints.py#L39-L75","documentation":"Error \"Failed to parse multipart form data: {e}. When using curl with --form/-F, do NOT set the Content-Type header manually — curl will set it automatically with the required boundary.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/ocr_endpoints/endpoints.py:57 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["When using curl with --form/-F, do not set the Content-Type header manually; let curl set it with the boundary."],"exampleFix":null,"handlingStrategy":null,"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-14T00:17:10.932Z"}