agentscope-ai/agentscope · error · ValueError
Unsupported media type {media_type!r} in DataBlock. Expected
Error message
Unsupported media type {media_type!r} in DataBlock. Expected image/* or video/*. What it means
_format_data_block only knows how to map image/* (base64 or URL) and video/* (URL) media types to DashScope's multimodal format; any other media_type in a DataBlock raises ValueError listing the unsupported type.
Source
Thrown at src/agentscope/embedding/_dashscope/_model.py:526
media_type = source.media_type
if media_type.startswith("video/"):
if not isinstance(source, URLSource):
raise ValueError(
"Multimodal embedding API only supports URL input "
f"for video data, got {type(source).__name__}.",
)
return {"video": str(source.url)}
if media_type.startswith("image/"):
if isinstance(source, Base64Source):
return {
"image": f"data:{media_type};" f"base64,{source.data}",
}
if isinstance(source, URLSource):
return {"image": str(source.url)}
raise ValueError(
f"Unsupported media type {media_type!r} in DataBlock. "
f"Expected image/* or video/*.",
)
View on GitHub (pinned to e90f1c7592)
Solutions
- Filter DataBlocks to image/* and video/* before calling the model
- Use a document/audio-specific embedding or conversion pipeline for other media types
- Set correct media_type values when building DataBlocks
Example fix
# before
await model(blocks) # blocks may contain audio/pdf
# after
ok = [b for b in blocks if b.source.media_type.startswith(("image/", "video/"))]
await model(ok) Defensive patterns
Strategy: validation
Validate before calling
blocks = [b for b in blocks if b.source.media_type.startswith((\"image/\", \"video/\"))]
Type guard
def is_supported_media(block) -> bool:\n return block.source.media_type.startswith((\"image/\", \"video/\"))
Try / catch
try:\n await model(blocks)\nexcept ValueError as e:\n if \"Unsupported media type\" in str(e): blocks = [b for b in blocks if is_supported_media(b)]; await model(blocks)\n else: raise
Prevention
- Set accurate media_type when creating DataBlocks
- Segment pipelines by media kind before embedding
When it happens
Trigger: Passing a DataBlock whose source.media_type is audio/*, application/pdf, text/plain, etc., to the multimodal embedding model.
Common situations: Feeding generic attachments (PDFs, audio) from a document pipeline into the embedding model; defaulting media_type incorrectly when constructing DataBlocks.
Related errors
- Invalid input: {item!r}. Expected str or DataBlock.
- DashScope multimodal embedding API error: {res}
- Multimodal embedding API only supports URL input for video d
- Text embedding model {self.model!r} only accepts str inputs,
- DashScope text embedding API error: {response}
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/4c7697e94a50474d.
Report an issue: GitHub.