agentscope-ai/agentscope · error · ValueError
Unsupported source type {type(source).__name__} in DataBlock
Error message
Unsupported source type {type(source).__name__} in DataBlock. What it means
A fallback guard in _data_block_to_part: the DataBlock's source is neither Base64Source nor URLSource (the two handled types). This almost always means a custom source class, a source left as None, or an object from an incompatible library version.
Source
Thrown at src/agentscope/embedding/_gemini/_model.py:482
if isinstance(source, Base64Source):
import base64
return types.Part.from_bytes(
data=base64.b64decode(source.data),
mime_type=source.media_type,
)
if isinstance(source, URLSource):
# Gemini SDK doesn't have a direct from_url for
# embed_content; download or use File API.
# For now, raise — callers should use Base64Source.
raise ValueError(
"Gemini embedding API requires inline data "
"(Base64Source). URLSource is not directly supported "
f"for embedding. Got URL: {source.url}",
)
raise ValueError(
f"Unsupported source type {type(source).__name__} "
f"in DataBlock.",
)
View on GitHub (pinned to e90f1c7592)
Solutions
- Print type(source) and its module to see what actually arrived; verify module paths match agentscope.message
- Ensure exactly one agentscope version is installed (pip show agentscope; clean venv)
- Set source to a real Base64Source (inline) or URLSource instance
Example fix
# before
block = DataBlock(source={"data": b"...", "media_type": "image/png"}) # dict source
# after
from agentscope.message import DataBlock, Base64Source
block = DataBlock(source=Base64Source(data=..., media_type="image/png")) Defensive patterns
Strategy: type-guard
Validate before calling
from agentscope.message import Base64Source, URLSource
for x in inputs:
src = getattr(x, "source", None)
assert isinstance(src, (Base64Source, URLSource)), type(src) Type guard
from agentscope.message import Base64Source, URLSource
def has_supported_source(block) -> bool:
return isinstance(getattr(block, "source", None), (Base64Source, URLSource)) Try / catch
try:
emb = await model(inputs=inputs)
except ValueError as e:
if "Unsupported source type" in str(e):
log_source_modules(inputs) # diagnose version mismatch, then rebuild blocks
raise
raise Prevention
- Pin one agentscope version per environment
- Always import DataBlock/source types from agentscope.message
- Never assign dicts or None as DataBlock.source
When it happens
Trigger: Passing a DataBlock whose source is None, a locally-defined source subclass, or a source dataclass from a different (mismatched) agentscope/version namespace, so isinstance checks fail.
Common situations: Mixing agentscope versions in one environment (DataBlock imported from an old installed copy while the model uses the new one); creating DataBlock(source=...) with a plain dict; subclassing source types without updating formatters/models.
Related errors
- Invalid input: {item!r}. Expected str or DataBlock.
- Text embedding model {self.model!r} only accepts str inputs,
- Gemini embedding API requires inline data (Base64Source). UR
- Unsupported source type: {type(source)}
- Text embedding model {self.model!r} only accepts str inputs,
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/4d75a6ced26a6616.
Report an issue: GitHub.