{"record":{"id":"1bc9fb37bf6fded6","repo":"BerriAI/litellm","slug":"multipart-ocr-request-must-include-a-file-field","errorCode":null,"errorMessage":"Multipart OCR request must include a 'file' field with the document to process","messagePattern":"Multipart OCR request must include a 'file' field with the document to process","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/ocr_endpoints/endpoints.py","lineNumber":68,"sourceCode":"\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:\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():","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/ocr_endpoints/endpoints.py#L50-L86","documentation":"ValueError raised while parsing an OCR proxy request as multipart/form-data: the form parsed successfully but contains no 'file' field, so there is no document to OCR. Fires when the client uploads without naming the file part 'file'.","triggerScenarios":"Thrown at litellm/proxy/ocr_endpoints/endpoints.py:68 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include a 'file' field with the document in the multipart/form-data request."],"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"}