{"record":{"id":"2726a40b7d35432a","repo":"deepset-ai/haystack","slug":"document-with-file-path-resolved-file-path-has","errorCode":null,"errorMessage":"Document with file path '{resolved_file_path}' has an unsupported MIME type '{mime_type}'. Please ensure that the documents you are trying to convert are of the supported types: {', '.join(IMAGE_MIME_TYPES)}.","messagePattern":"Document with file path '(.+?)' has an unsupported MIME type '(.+?)'\\. Please ensure that the documents you are trying to convert are of the supported types: (.+?)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"haystack/components/converters/image/image_utils.py","lineNumber":273,"sourceCode":"        # process untrusted metadata should configure root_path (see component docstrings).\n        if root_path:\n            resolved_file_path = resolved_file_path.resolve()\n            resolved_root = Path(root_path).resolve()\n            if not resolved_file_path.is_relative_to(resolved_root):\n                raise ValueError(\n                    f\"Document with ID '{doc.id}' has a file path '{file_path}' that escapes the \"\n                    f\"configured root '{root_path}'. Resolved path: '{resolved_file_path}'.\"\n                )\n\n        if not resolved_file_path.is_file():\n            raise ValueError(\n                f\"Document with ID '{doc.id}' has an invalid file path '{resolved_file_path}'. \"\n                f\"Please ensure that the documents you are trying to convert have valid file paths.\"\n            )\n\n        mime_type = doc.meta.get(\"mime_type\") or mimetypes.guess_type(resolved_file_path)[0]\n        if mime_type not in IMAGE_MIME_TYPES:\n            raise ValueError(\n                f\"Document with file path '{resolved_file_path}' has an unsupported MIME type '{mime_type}'. \"\n                f\"Please ensure that the documents you are trying to convert are of the supported \"\n                f\"types: {', '.join(IMAGE_MIME_TYPES)}.\"\n            )\n\n        image_info: _ImageSourceInfo = {\"path\": resolved_file_path, \"mime_type\": mime_type}\n\n        # If mimetype is PDF we also need the page number to be able to convert the right page\n        if mime_type == \"application/pdf\":\n            page_number = doc.meta.get(\"page_number\")\n            if page_number is None:\n                raise ValueError(\n                    f\"Document with ID '{doc.id}' comes from the PDF file '{resolved_file_path}' but is missing \"\n                    f\"the 'page_number' key in its metadata. Please ensure that PDF documents you are trying to \"\n                    f\"convert have this key set.\"\n                )\n            image_info[\"page_number\"] = page_number\n","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/converters/image/image_utils.py#L255-L291","documentation":"The component only accepts image MIME types in IMAGE_MIME_TYPES. The MIME type comes from document meta 'mime_type' or is guessed from the file extension; if the result is not a supported image type (or None), it raises ValueError listing the supported types.","triggerScenarios":"meta['mime_type']='application/pdf' or 'text/plain' on a Document passed to the image converter; files with extensions mimetypes can't map (mime_type None); passing non-image files like .txt or .docx.","commonSituations":"Wrong pipeline wiring (feeding text documents to an image converter); files saved without proper extension; meta mime_type manually set incorrectly; exotic formats (HEIC, BMP variants) not in IMAGE_MIME_TYPES.","solutions":["Convert the file to a supported image format (e.g. PNG/JPEG) first.","Remove/fix a wrong meta['mime_type'] so it matches the actual image type.","Rename the file with a proper image extension so mimetypes.guess_type resolves correctly.","Check IMAGE_MIME_TYPES in haystack/components/converters/image/image_utils.py for the supported set."],"exampleFix":"// before\ndoc.meta[\"mime_type\"] = \"application/pdf\"\nconverter.run(documents=docs)\n// after\ndoc.meta[\"mime_type\"] = \"image/png\"\nconverter.run(documents=docs)","handlingStrategy":"validation","validationCode":"import mimetypes\nfrom haystack.components.converters.image.image_utils import IMAGE_MIME_TYPES\n\ndef filter_supported_images(docs):\n    ok = []\n    for d in docs:\n        mime = d.meta.get(\"mime_type\") or mimetypes.guess_type(d.meta.get(\"file_path\", \"\"))[0]\n        if mime in IMAGE_MIME_TYPES:\n            ok.append(d)\n        else:\n            logger.warning(\"Skipping %s: unsupported MIME %s\", d.id, mime)\n    return ok","typeGuard":"def is_supported_image(doc) -> bool:\n    import mimetypes\n    from haystack.components.converters.image.image_utils import IMAGE_MIME_TYPES\n    mime = doc.meta.get(\"mime_type\") or mimetypes.guess_type(doc.meta.get(\"file_path\", \"\"))[0]\n    return mime in IMAGE_MIME_TYPES","tryCatchPattern":"try:\n    result = converter.run(documents=docs)\nexcept ValueError as e:\n    if \"unsupported MIME type\" in str(e):\n        bad_path = str(e).split(\"'\")[1]\n        docs = [d for d in docs if str(d.meta.get(\"file_path\")) != bad_path]\n        result = converter.run(documents=docs) if docs else {\"images\": []}\n    else:\n        raise","preventionTips":["Only wire image documents into image converters; route other types elsewhere.","Set meta['mime_type'] accurately or rely on proper file extensions.","Convert non-image files (HEIC, TIFF variants) to PNG/JPEG first.","Check IMAGE_MIME_TYPES for the exact supported set before ingestion."],"tags":["python","mimetype","unsupported-format","image"],"backgroundTag":"unsupported-file-format","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}