{"record":{"id":"b084fc0480677943","repo":"deepset-ai/haystack","slug":"document-with-id-doc-id-has-an-invalid-file-pa","errorCode":null,"errorMessage":"Document with ID '{doc.id}' has an invalid file path '{resolved_file_path}'. Please ensure that the documents you are trying to convert have valid file paths.","messagePattern":"Document with ID '(.+?)' has an invalid file path '(.+?)'\\. Please ensure that the documents you are trying to convert have valid file paths\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"haystack/components/converters/image/image_utils.py","lineNumber":266,"sourceCode":"            )\n\n        resolved_file_path = Path(root_path, file_path)\n\n        # When root_path is set, ensure the resolved path stays within it to block path-traversal\n        # payloads (e.g. \"../../etc/passwd\") coming from document metadata. When root_path is unset,\n        # file paths are treated as absolute by design and no containment check is applied; callers that\n        # 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:","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/converters/image/image_utils.py#L248-L284","documentation":"After containment checks, the component verifies the resolved path actually exists and is a regular file via Path.is_file(). Missing files, directories, or broken symlinks raise this ValueError naming the resolved path and Document ID.","triggerScenarios":"Document meta file_path points to a non-existent file, a directory, or a broken symlink; files deleted/moved after indexing; wrong root_path making resolved path not exist.","commonSituations":"Index built on another machine/container where files aren't mounted; temp files cleaned up; paths stored before a data migration; case-sensitivity mismatch on Linux (Image.PNG vs image.png).","solutions":["Verify the file exists: Path(root_path, file_path).is_file() before running.","Fix the file_path value in document metadata or re-index with correct paths.","Copy/mount the missing files into the expected location.","Check filename case and extensions match exactly on disk."],"exampleFix":"// before\ndoc.meta[\"file_path\"] = \"/data/old_run/img.png\"  # file deleted\nconverter.run(documents=docs)\n// after\nassert Path(doc.meta[\"file_path\"]).is_file()\ndoc.meta[\"file_path\"] = \"/data/new_run/img.png\"\nconverter.run(documents=docs)","handlingStrategy":"validation","validationCode":"from pathlib import Path\ndef filter_existing(docs, root_path=None, key=\"file_path\"):\n    ok = []\n    for d in docs:\n        p = Path(root_path, d.meta.get(key, \"\")) if root_path else Path(d.meta.get(key, \"\"))\n        if p.is_file():\n            ok.append(d)\n        else:\n            logger.warning(\"Skipping %s: %s does not exist\", d.id, p)\n    return ok","typeGuard":"def file_exists(doc, root=None, key=\"file_path\") -> bool:\n    fp = doc.meta.get(key)\n    if not isinstance(fp, str):\n        return False\n    return (Path(root, fp) if root else Path(fp)).is_file()","tryCatchPattern":"try:\n    result = converter.run(documents=docs)\nexcept ValueError as e:\n    if \"invalid file path\" in str(e):\n        bad = str(e).split(\"'\")[1]\n        docs = [d for d in docs if str(Path(d.meta[\"file_path\"])) != bad]\n        result = converter.run(documents=docs) if docs else {\"images\": []}\n    else:\n        raise","preventionTips":["Check Path(file_path).is_file() for each document before running.","Re-index after moving/migrating data files.","Mount the same data volume your indexer used.","Watch Linux case-sensitivity; verify exact filenames."],"tags":["python","filesystem","file-not-found","image"],"backgroundTag":"file-not-found","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}