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

  1. Print type(source) and its module to see what actually arrived; verify module paths match agentscope.message
  2. Ensure exactly one agentscope version is installed (pip show agentscope; clean venv)
  3. 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

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


AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28). Data as JSON: /api/errors/4d75a6ced26a6616. Report an issue: GitHub.