{"record":{"id":"c9e05c487adc1ee6","repo":"run-llama/llama_index","slug":"the-specified-url-is-not-an-accessible-image","errorCode":null,"errorMessage":"The specified URL is not an accessible image","messagePattern":"The specified URL is not an accessible image","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/schema.py","lineNumber":1352,"sourceCode":"        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\n    @image.setter\n    def image(self, image: str) -> None:\n        self.image_resource = MediaResource(data=image.encode(\"utf-8\"))\n\n    @property\n    def image_path(self) -> str | None:","sourceCodeStart":1334,"sourceCodeEnd":1370,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/schema.py#L1334-L1370","documentation":"Document's media-resource constructor validates image_url by checking the URL is an accessible image (is_image_url_pil). If the URL is malformed, unreachable, returns a non-image (HTML error page, 404), or the payload is not a valid image, construction raises ValueError('The specified URL is not an accessible image').","triggerScenarios":"Creating Document(image_url=u) where u returns 404/403, points to an HTML page, is an unsupported format, or the host is unreachable/slow (network egress blocked in containers).","commonSituations":"Scraped URLs that expired or redirect to login pages; signed S3/CDN URLs that expired; running in sandboxes without network access; URLs with trailing spaces or missing scheme.","solutions":["Check the URL first: requests.head(u) expecting status 200 and an image/* content-type","Fix or refresh expired/signed URLs before ingestion","Download the bytes yourself and pass image= (base64) so you control errors and retries"],"exampleFix":"# before\ndoc = Document(image_url=url)  # ValueError on 404/HTML\n\n# after\nimport requests\nresp = requests.head(url, timeout=10, allow_redirects=True)\nif resp.ok and resp.headers.get(\"content-type\", \"\").startswith(\"image/\"):\n    doc = Document(image_url=url)\nelse:\n    raise RuntimeError(f\"bad image url {url}: {resp.status_code}\")","handlingStrategy":"validation","validationCode":"import requests\nr = requests.head(url, timeout=10, allow_redirects=True)\nok = r.ok and r.headers.get(\"content-type\", \"\").startswith(\"image/\")","typeGuard":"def is_fetchable_image_url(u: str) -> bool:\n    try:\n        r = requests.head(u, timeout=10, allow_redirects=True)\n        return r.ok and r.headers.get(\"content-type\", \"\").startswith(\"image/\")\n    except requests.RequestException:\n        return False","tryCatchPattern":"try:\n    doc = Document(image_url=url)\nexcept ValueError:\n    # download bytes yourself and pass image=base64 instead\n    ...","preventionTips":["HEAD-check URLs before ingestion","Refresh expiring signed URLs at ingest time","Download bytes locally and pass base64 when network is unreliable"],"tags":["schema","multimodal","images","network","validation"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}