{"record":{"id":"95a138f901feeb93","repo":"run-llama/llama_index","slug":"no-image-found-in-the-chat-message","errorCode":null,"errorMessage":"No image found in the chat message!","messagePattern":"No image found in the chat message!","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/schema.py","lineNumber":1445,"sourceCode":"\n        if self.image_resource.data is not None:\n            if as_base64:\n                return BytesIO(self.image_resource.data)\n            return BytesIO(base64.b64decode(self.image_resource.data))\n        elif self.image_resource.path is not None:\n            img_bytes = self.image_resource.path.read_bytes()\n            if as_base64:\n                return BytesIO(base64.b64encode(img_bytes))\n            return BytesIO(img_bytes)\n        elif self.image_resource.url is not None:\n            # load image from URL\n            response = requests.get(str(self.image_resource.url), timeout=(60, 60))\n            img_bytes = response.content\n            if as_base64:\n                return BytesIO(base64.b64encode(img_bytes))\n            return BytesIO(img_bytes)\n        else:\n            raise ValueError(\"No image found in the chat message!\")\n\n\n@dataclass\nclass QueryBundle(DataClassJsonMixin):\n    \"\"\"\n    Query bundle.\n\n    This dataclass contains the original query string and associated transformations.\n\n    Args:\n        query_str (str): the original user-specified query string.\n            This is currently used by all non embedding-based queries.\n        custom_embedding_strs (list[str]): list of strings used for embedding the query.\n            This is currently used by all embedding-based queries.\n        embedding (list[float]): the stored embedding for the query.\n\n    \"\"\"\n","sourceCodeStart":1427,"sourceCodeEnd":1463,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/schema.py#L1427-L1463","documentation":"ChatMessage's image resolution walks its MediaResource: data (base64), then path, then url. If image_resource exists but none of data/path/url is populated (or there is no usable image attached), it raises ValueError('No image found in the chat message!'). This is the terminal else of the resolution chain.","triggerScenarios":"Calling chat_message.resolve_image() (directly or via a multi-modal LLM flow) on a ChatMessage whose image_resource is empty or whose only image content failed to attach — e.g. built via chat message construction with an empty MediaResource.","commonSituations":"Programmatically assembling multi-modal ChatMessages where the image attach step was skipped or passed empty values; empty string values for all three sources after data cleanup.","solutions":["Attach a real source: pass image bytes (data), a valid path, or a reachable URL when creating the message","Check msg.image_resource and which of .data/.path/.url is set before resolving","Skip resolve_image for text-only messages instead of calling it unconditionally"],"exampleFix":"# before\nmsgs.append(ChatMessage(role=\"user\", content=\"describe\"))  # image never attached\nimg = msgs[-1].resolve_image()  # ValueError\n\n# after\nfrom llama_index.core.base.llms.types import ChatMessage\nmsgs.append(ChatMessage(role=\"user\", content=\"describe\", image_resource=MediaResource(path=img_path)))","handlingStrategy":"validation","validationCode":"res = getattr(msg, \"image_resource\", None)\nhas_img = res is not None and (res.data or res.path or res.url)","typeGuard":"def message_has_image(msg) -> bool:\n    res = getattr(msg, \"image_resource\", None)\n    return res is not None and bool(res.data or res.path or res.url)","tryCatchPattern":null,"preventionTips":["Attach MediaResource with a concrete source when building multi-modal messages","Guard resolve_image() with a source check","Never pass empty strings as image sources"],"tags":["schema","multimodal","chat","images"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}