HKUDS/Vibe-Trading · error · ValueError

__dataframe__ needs a 'data' list of rows

Error message

__dataframe__ needs a 'data' list of rows

What it means

Raised by quantlib_tool._decode when a value carries the __dataframe__ marker but its payload is not a dict containing a 'data' key. The expected envelope is {'__dataframe__': {'data': [[row], ...], 'index': [...], 'columns': [...]}}; a missing/misspelled 'data' key or a non-dict spec aborts decoding.

Source

Thrown at agent/src/tools/quantlib_tool.py:158

    Returns:
        The value with any envelope replaced by the pandas object it describes.

    Raises:
        ValueError: If an envelope is malformed.
    """
    import pandas as pd

    if isinstance(value, dict):
        if "__series__" in value:
            spec = value["__series__"]
            if not isinstance(spec, dict) or "values" not in spec:
                raise ValueError("__series__ needs a 'values' list")
            return pd.Series(spec["values"], index=spec.get("index"))
        if "__dataframe__" in value:
            spec = value["__dataframe__"]
            if not isinstance(spec, dict) or "data" not in spec:
                raise ValueError("__dataframe__ needs a 'data' list of rows")
            return pd.DataFrame(
                spec["data"], index=spec.get("index"), columns=spec.get("columns")
            )
        return {k: _decode(v) for k, v in value.items()}
    if isinstance(value, list):
        return [_decode(v) for v in value]
    return value


class _Budget:
    """Mutable leaf counter shared across one serialization pass."""

    def __init__(self) -> None:
        self.leaves = 0
        self.truncated = False


def _encode(value: Any, budget: _Budget) -> Any:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Include a 'data' key holding a list of rows: {'__dataframe__': {'data': [[...], [...]], 'columns': [...]}}
  2. Verify the key is exactly 'data' (not 'rows', 'values', 'records')
  3. Pass plain nested lists and build the DataFrame inside the call if the encoding isn't required

Example fix

# before
{"__dataframe__": {"rows": [[1, 2], [3, 4]], "columns": ["a", "b"]}}

# after
{"__dataframe__": {"data": [[1, 2], [3, 4]], "columns": ["a", "b"]}}
Defensive patterns

Strategy: type-guard

Type guard

def is_valid_dataframe_envelope(v: object) -> bool:
    return (
        isinstance(v, dict)
        and set(v) == {"__dataframe__"}
        and isinstance(v["__dataframe__"], dict)
        and isinstance(v["__dataframe__"].get("data"), list)
    )

Try / catch

try:
    decoded = _decode(payload)
except ValueError as e:
    if "__dataframe__" in str(e):
        spec = payload["__dataframe__"]
        spec["data"] = spec.pop("rows", spec.pop("values", []))  # repair and retry
        decoded = _decode(payload)

Prevention

When it happens

Trigger: Passing {'__dataframe__': {'rows': [...]}} (key misspelled); {'__dataframe__': {'index': [...], 'columns': [...]}} with data omitted; {'__dataframe__': [...]}; or constructing the envelope with values instead of row-arrays.

Common situations: Hand-written or LLM-generated tool arguments guessing the dataframe encoding; programmatic envelope builders with key-name bugs; stale callers written against an older/newer envelope format.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/0c1aeccf41b77d74. Report an issue: GitHub.