{"record":{"id":"acca776b5d32d12e","repo":"HKUDS/Vibe-Trading","slug":"valuations-index-must-be-an-object-with-date-an","errorCode":null,"errorMessage":"valuations[{index}] must be an object with date and value","messagePattern":"valuations\\[(.+?)\\] must be an object with date and value","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/cashflow_analytics_tool.py","lineNumber":324,"sourceCode":"    Args:\n        raw: Value supplied for the ``valuations`` parameter.\n\n    Returns:\n        Pairs in the order supplied; the library sorts and validates them.\n\n    Raises:\n        ValueError: If the array is missing, wrongly shaped, over the size cap,\n            or an entry lacks a usable date or value.\n    \"\"\"\n    if not isinstance(raw, list) or len(raw) < 2:\n        raise ValueError(\"valuations must be an array of at least two {date, value} objects\")\n    if len(raw) > _MAX_VALUATIONS:\n        raise ValueError(f\"valuations may contain at most {_MAX_VALUATIONS} entries\")\n\n    pairs: list[tuple[date, float]] = []\n    for index, item in enumerate(raw):\n        if not isinstance(item, dict):\n            raise ValueError(f\"valuations[{index}] must be an object with date and value\")\n        if \"date\" not in item or \"value\" not in item:\n            raise ValueError(f\"valuations[{index}] needs both 'date' and 'value'\")\n        try:\n            value = float(item[\"value\"])\n        except (TypeError, ValueError) as exc:\n            raise ValueError(f\"valuations[{index}].value must be numeric\") from exc\n        if not math.isfinite(value):\n            raise ValueError(f\"valuations[{index}].value must be finite\")\n        pairs.append((item[\"date\"], value))\n    return pairs\n\n\ndef _resolve_flows(kwargs: dict[str, Any]) -> CashFlowSeries | None:\n    \"\"\"Build the cash-flow series from inline records or from a file.\n\n    Args:\n        kwargs: The tool's raw inputs.\n","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/cashflow_analytics_tool.py#L306-L342","documentation":"Each element of the valuations array must be a dict (JSON object) containing date and value. Non-dict entries (strings, numbers, nested lists) fail this per-index check before field validation begins.","triggerScenarios":"Calling execute with valuations=['2024-01-01', ...], [[date, value], ...], or mixed arrays where some entries are scalars.","commonSituations":"Tuple/array-style rows from pandas itertuples or zip; LLM emitting shorthand formats; converting CSVs where each row becomes a list.","solutions":["Map rows to dicts: [{'date': d, 'value': v} for d, v in rows]","When iterating a DataFrame, use .to_dict('records')","Validate element shape with isinstance(item, dict) before submitting"],"exampleFix":"# before\nvaluations=list(zip(dates, values))  # [(d, v), ...]\n# after\nvaluations=[{'date': d, 'value': v} for d, v in zip(dates, values)]","handlingStrategy":"type-guard","validationCode":"assert all(isinstance(i, dict) and {'date','value'} <= i.keys() for i in valuations)","typeGuard":"def entries_are_objects(v: list) -> bool:\n    return all(isinstance(i, dict) for i in v)","tryCatchPattern":"try:\n    tool.execute(valuations=valuations)\nexcept ValueError as e:\n    if 'must be an object' in str(e):\n        valuations = [{'date': d, 'value': val} for d, val in v]  # reshape rows","preventionTips":["Use DataFrame.to_dict('records') when converting tabular data","Never forward zip/tuple rows as JSON arrays"],"tags":["validation","payload-shape","cashflow-analytics"],"backgroundTag":"schema-validation-failed","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}