run-llama/llama_index · error · ValueError
No image found in the chat message!
Error message
No image found in the chat message!
What it means
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.
Source
Thrown at llama-index-core/llama_index/core/schema.py:1445
if self.image_resource.data is not None:
if as_base64:
return BytesIO(self.image_resource.data)
return BytesIO(base64.b64decode(self.image_resource.data))
elif self.image_resource.path is not None:
img_bytes = self.image_resource.path.read_bytes()
if as_base64:
return BytesIO(base64.b64encode(img_bytes))
return BytesIO(img_bytes)
elif self.image_resource.url is not None:
# load image from URL
response = requests.get(str(self.image_resource.url), timeout=(60, 60))
img_bytes = response.content
if as_base64:
return BytesIO(base64.b64encode(img_bytes))
return BytesIO(img_bytes)
else:
raise ValueError("No image found in the chat message!")
@dataclass
class QueryBundle(DataClassJsonMixin):
"""
Query bundle.
This dataclass contains the original query string and associated transformations.
Args:
query_str (str): the original user-specified query string.
This is currently used by all non embedding-based queries.
custom_embedding_strs (list[str]): list of strings used for embedding the query.
This is currently used by all embedding-based queries.
embedding (list[float]): the stored embedding for the query.
"""
View on GitHub (pinned to afd0fef371)
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
Example fix
# before msgs.append(ChatMessage(role="user", content="describe")) # image never attached img = msgs[-1].resolve_image() # ValueError # after from llama_index.core.base.llms.types import ChatMessage msgs.append(ChatMessage(role="user", content="describe", image_resource=MediaResource(path=img_path)))
Defensive patterns
Strategy: validation
Validate before calling
res = getattr(msg, "image_resource", None) has_img = res is not None and (res.data or res.path or res.url)
Type guard
def message_has_image(msg) -> bool:
res = getattr(msg, "image_resource", None)
return res is not None and bool(res.data or res.path or res.url) Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No image found in node.
- The specified file path is not an accessible image
- The specified URL is not an accessible image
- A retrieved image must have image_path or image_url specifie
- Node must be a TextNode to get text.
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/95a138f901feeb93.
Report an issue: GitHub.