{"record":{"id":"1cba2a836fe135b0","repo":"BerriAI/litellm","slug":"invalid-mime-type-mime-type","errorCode":null,"errorMessage":"Invalid MIME type: {mime_type}","messagePattern":"Invalid MIME type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/ocr/main.py","lineNumber":549,"sourceCode":"            file_name = getattr(file_input, \"name\", None)\n            if file_name:\n                mime_type = get_mime_type(file_name)\n        file_bytes = file_input.read()\n        if isinstance(file_bytes, str):\n            file_bytes = file_bytes.encode(\"utf-8\")\n    else:\n        raise ValueError(\n            f\"Unsupported file input type: {type(file_input)}. Expected pathlib.Path, bytes, or a file-like object.\"\n        )\n\n    if not file_bytes:\n        raise ValueError(\"File is empty or could not be read\")\n\n    if \"mime_type\" in document:\n        mime_type = document[\"mime_type\"]\n\n    if not _MIME_PATTERN.match(mime_type):\n        raise ValueError(f\"Invalid MIME type: {mime_type}\")\n\n    base64_data: Final = base64.b64encode(file_bytes).decode(\"utf-8\")\n    data_uri: Final = f\"data:{mime_type};base64,{base64_data}\"\n\n    if mime_type.startswith(\"image/\"):\n        verbose_logger.debug(\n            \"OCR file input: Converted file to image_url data URI (mime=%s, size=%s bytes, name=%s)\",\n            mime_type,\n            len(file_bytes),\n            file_name,\n        )\n        return {\"type\": \"image_url\", \"image_url\": data_uri}\n\n    verbose_logger.debug(\n        \"OCR file input: Converted file to document_url data URI (mime=%s, size=%s bytes, name=%s)\",\n        mime_type,\n        len(file_bytes),\n        file_name,","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/ocr/main.py#L531-L567","documentation":"Raised when the resolved MIME type (from the filename, file object name, or document['mime_type'] override) is not a valid MIME string, so it cannot be embedded in the base64 data URI for the OCR request.","triggerScenarios":"Thrown at litellm/ocr/main.py:549 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a supported MIME type (e.g. application/pdf, image/png).","Check the file extension matches its actual content."],"exampleFix":"mime_type='application/pdf'","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"}