{"record":{"id":"d86b33c0ca630257","repo":"run-llama/llama_index","slug":"the-specified-file-path-is-not-an-accessible-image","errorCode":null,"errorMessage":"The specified file path is not an accessible image","messagePattern":"The specified file path is not an accessible image","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/schema.py","lineNumber":1346,"sourceCode":"\n\nclass ImageDocument(Document):\n    \"\"\"Backward compatible wrapper around Document containing an image.\"\"\"\n\n    def __init__(self, **kwargs: Any) -> None:\n        image = kwargs.pop(\"image\", None)\n        image_path = kwargs.pop(\"image_path\", None)\n        image_url = kwargs.pop(\"image_url\", None)\n        image_mimetype = kwargs.pop(\"image_mimetype\", None)\n        text_embedding = kwargs.pop(\"text_embedding\", None)\n\n        if image:\n            kwargs[\"image_resource\"] = MediaResource(\n                data=image, mimetype=image_mimetype\n            )\n        elif image_path:\n            if not is_image_pil(image_path):\n                raise ValueError(\"The specified file path is not an accessible image\")\n            kwargs[\"image_resource\"] = MediaResource(\n                path=image_path, mimetype=image_mimetype\n            )\n        elif image_url:\n            if not is_image_url_pil(image_url):\n                raise ValueError(\"The specified URL is not an accessible image\")\n            kwargs[\"image_resource\"] = MediaResource(\n                url=image_url, mimetype=image_mimetype\n            )\n\n        super().__init__(**kwargs)\n\n    @property\n    def image(self) -> str | None:\n        if self.image_resource and self.image_resource.data:\n            return self.image_resource.data.decode(\"utf-8\")\n        return None\n","sourceCodeStart":1328,"sourceCodeEnd":1364,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/schema.py#L1328-L1364","documentation":"Document's newer media-resource constructor validates image_path with an image sanity check (is_image_pil). If Pillow cannot open/verify the file at that path — missing, corrupt, or not an image — construction fails immediately with ValueError('The specified file path is not an accessible image').","triggerScenarios":"Creating Document(image_path=p) where p does not exist, points to a non-image file, or a corrupt/truncated image; also paths that exist but lack read permission.","commonSituations":"Bulk-ingesting directories where some files are mislabeled or zero-byte; path bugs (relative vs absolute) when running readers in containers; images in formats Pillow cannot read.","solutions":["Verify the path exists, is readable, and is a real image before constructing the Document","Pre-open with PIL: Image.open(p).verify() to reproduce and catch the exact failure","Skip/quarantine bad files in bulk ingestion instead of aborting the whole run"],"exampleFix":"# before\ndoc = Document(image_path=p, text=\"photo\")  # ValueError on bad file\n\n# after\nfrom PIL import Image\ntry:\n    with Image.open(p) as im:\n        im.verify()\n    doc = Document(image_path=p, text=\"photo\")\nexcept Exception:\n    logger.warning(\"skipping unreadable image %s\", p)","handlingStrategy":"validation","validationCode":"from pathlib import Path\nfrom PIL import Image\np = Path(image_path)\nassert p.is_file(), f\"missing image: {p}\"\nwith Image.open(p) as im:\n    im.verify()  # raises now, not inside Document()","typeGuard":"def is_valid_image_file(p: str) -> bool:\n    try:\n        with Image.open(p) as im:\n            im.verify()\n        return True\n    except Exception:\n        return False","tryCatchPattern":"try:\n    doc = Document(image_path=p, text=caption)\nexcept ValueError:\n    logger.warning(\"skipping unreadable image %s\", p)\n    continue","preventionTips":["Validate image files during bulk ingest, not at Document construction","Use absolute paths in containerized runs","Quarantine unreadable images instead of aborting pipelines"],"tags":["schema","multimodal","images","file-io","validation"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}