deepset-ai/haystack · error

Document with file path '{resolved_file_path}' has an unsupp

Error message

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)}.

What it means

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.

Source

Thrown at haystack/components/converters/image/image_utils.py:273

        # process untrusted metadata should configure root_path (see component docstrings).
        if root_path:
            resolved_file_path = resolved_file_path.resolve()
            resolved_root = Path(root_path).resolve()
            if not resolved_file_path.is_relative_to(resolved_root):
                raise ValueError(
                    f"Document with ID '{doc.id}' has a file path '{file_path}' that escapes the "
                    f"configured root '{root_path}'. Resolved path: '{resolved_file_path}'."
                )

        if not resolved_file_path.is_file():
            raise ValueError(
                f"Document with ID '{doc.id}' has an invalid file path '{resolved_file_path}'. "
                f"Please ensure that the documents you are trying to convert have valid file paths."
            )

        mime_type = doc.meta.get("mime_type") or mimetypes.guess_type(resolved_file_path)[0]
        if mime_type not in IMAGE_MIME_TYPES:
            raise ValueError(
                f"Document with file path '{resolved_file_path}' has an unsupported MIME type '{mime_type}'. "
                f"Please ensure that the documents you are trying to convert are of the supported "
                f"types: {', '.join(IMAGE_MIME_TYPES)}."
            )

        image_info: _ImageSourceInfo = {"path": resolved_file_path, "mime_type": mime_type}

        # If mimetype is PDF we also need the page number to be able to convert the right page
        if mime_type == "application/pdf":
            page_number = doc.meta.get("page_number")
            if page_number is None:
                raise ValueError(
                    f"Document with ID '{doc.id}' comes from the PDF file '{resolved_file_path}' but is missing "
                    f"the 'page_number' key in its metadata. Please ensure that PDF documents you are trying to "
                    f"convert have this key set."
                )
            image_info["page_number"] = page_number

View on GitHub (pinned to e318778c9b)

Solutions

  1. Convert the file to a supported image format (e.g. PNG/JPEG) first.
  2. Remove/fix a wrong meta['mime_type'] so it matches the actual image type.
  3. Rename the file with a proper image extension so mimetypes.guess_type resolves correctly.
  4. Check IMAGE_MIME_TYPES in haystack/components/converters/image/image_utils.py for the supported set.

Example fix

// before
doc.meta["mime_type"] = "application/pdf"
converter.run(documents=docs)
// after
doc.meta["mime_type"] = "image/png"
converter.run(documents=docs)
Defensive patterns

Strategy: validation

Validate before calling

import mimetypes
from haystack.components.converters.image.image_utils import IMAGE_MIME_TYPES

def filter_supported_images(docs):
    ok = []
    for d in docs:
        mime = d.meta.get("mime_type") or mimetypes.guess_type(d.meta.get("file_path", ""))[0]
        if mime in IMAGE_MIME_TYPES:
            ok.append(d)
        else:
            logger.warning("Skipping %s: unsupported MIME %s", d.id, mime)
    return ok

Type guard

def is_supported_image(doc) -> bool:
    import mimetypes
    from haystack.components.converters.image.image_utils import IMAGE_MIME_TYPES
    mime = doc.meta.get("mime_type") or mimetypes.guess_type(doc.meta.get("file_path", ""))[0]
    return mime in IMAGE_MIME_TYPES

Try / catch

try:
    result = converter.run(documents=docs)
except ValueError as e:
    if "unsupported MIME type" in str(e):
        bad_path = str(e).split("'")[1]
        docs = [d for d in docs if str(d.meta.get("file_path")) != bad_path]
        result = converter.run(documents=docs) if docs else {"images": []}
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30). Data as JSON: /api/errors/2726a40b7d35432a. Report an issue: GitHub.