{"record":{"id":"0c1aeccf41b77d74","repo":"HKUDS/Vibe-Trading","slug":"dataframe-needs-a-data-list-of-rows","errorCode":null,"errorMessage":"__dataframe__ needs a 'data' list of rows","messagePattern":"__dataframe__ needs a 'data' list of rows","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/quantlib_tool.py","lineNumber":158,"sourceCode":"\n    Returns:\n        The value with any envelope replaced by the pandas object it describes.\n\n    Raises:\n        ValueError: If an envelope is malformed.\n    \"\"\"\n    import pandas as pd\n\n    if isinstance(value, dict):\n        if \"__series__\" in value:\n            spec = value[\"__series__\"]\n            if not isinstance(spec, dict) or \"values\" not in spec:\n                raise ValueError(\"__series__ needs a 'values' list\")\n            return pd.Series(spec[\"values\"], index=spec.get(\"index\"))\n        if \"__dataframe__\" in value:\n            spec = value[\"__dataframe__\"]\n            if not isinstance(spec, dict) or \"data\" not in spec:\n                raise ValueError(\"__dataframe__ needs a 'data' list of rows\")\n            return pd.DataFrame(\n                spec[\"data\"], index=spec.get(\"index\"), columns=spec.get(\"columns\")\n            )\n        return {k: _decode(v) for k, v in value.items()}\n    if isinstance(value, list):\n        return [_decode(v) for v in value]\n    return value\n\n\nclass _Budget:\n    \"\"\"Mutable leaf counter shared across one serialization pass.\"\"\"\n\n    def __init__(self) -> None:\n        self.leaves = 0\n        self.truncated = False\n\n\ndef _encode(value: Any, budget: _Budget) -> Any:","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/quantlib_tool.py#L140-L176","documentation":"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.","triggerScenarios":"Passing {'__dataframe__': {'rows': [...]}} (key misspelled); {'__dataframe__': {'index': [...], 'columns': [...]}} with data omitted; {'__dataframe__': [...]}; or constructing the envelope with values instead of row-arrays.","commonSituations":"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.","solutions":["Include a 'data' key holding a list of rows: {'__dataframe__': {'data': [[...], [...]], 'columns': [...]}}","Verify the key is exactly 'data' (not 'rows', 'values', 'records')","Pass plain nested lists and build the DataFrame inside the call if the encoding isn't required"],"exampleFix":"# before\n{\"__dataframe__\": {\"rows\": [[1, 2], [3, 4]], \"columns\": [\"a\", \"b\"]}}\n\n# after\n{\"__dataframe__\": {\"data\": [[1, 2], [3, 4]], \"columns\": [\"a\", \"b\"]}}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def is_valid_dataframe_envelope(v: object) -> bool:\n    return (\n        isinstance(v, dict)\n        and set(v) == {\"__dataframe__\"}\n        and isinstance(v[\"__dataframe__\"], dict)\n        and isinstance(v[\"__dataframe__\"].get(\"data\"), list)\n    )","tryCatchPattern":"try:\n    decoded = _decode(payload)\nexcept ValueError as e:\n    if \"__dataframe__\" in str(e):\n        spec = payload[\"__dataframe__\"]\n        spec[\"data\"] = spec.pop(\"rows\", spec.pop(\"values\", []))  # repair and retry\n        decoded = _decode(payload)","preventionTips":["Construct envelopes with a helper that always emits a 'data' key","Round-trip encode/decode in tests to catch schema drift early","Keep 'columns' length equal to each row's length to avoid downstream frame errors"],"tags":["quantlib","serialization","pandas","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}