{"record":{"id":"747bf6c2f67e6917","repo":"HKUDS/Vibe-Trading","slug":"valuations-index-value-must-be-numeric","errorCode":null,"errorMessage":"valuations[{index}].value must be numeric","messagePattern":"valuations\\[(.+?)\\]\\.value must be numeric","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/cashflow_analytics_tool.py","lineNumber":330,"sourceCode":"    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\n    Returns:\n        A ``CashFlowSeries``, or ``None`` when no flows were supplied.\n\n    Raises:\n        ValueError: If both sources were given, an inline record is malformed,\n            or a currency is missing. File problems surface as","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/cashflow_analytics_tool.py#L312-L348","documentation":"Thrown when float(item[\"value\"]) raises TypeError or ValueError while coercing a valuation's value. The tool requires each value to be convertible to a finite float; strings like \"abc\" or null/non-numeric types fail here. The original exception is chained for debugging.","triggerScenarios":"valuations=[{\"date\": \"2024-01-01\", \"value\": \"abc\"}], value=None (TypeError from float(None)), or a string containing a non-numeric character.","commonSituations":"Values arriving as formatted strings from spreadsheets/CSV exports (\"1,000.50\", \"$100\", \"N/A\"), null placeholders for missing data, or values copied from JSON with stray characters.","solutions":["Pass values as JSON numbers, or clean strings to plain numeric form before calling","Strip currency symbols, commas, and whitespace from string values (e.g. float(v.replace(',','').replace('$','')))","Replace null/empty values by dropping that valuation entry"],"exampleFix":"// before\n{\"date\": \"2024-06-30\", \"value\": \"1,050.00 USD\"}\n// after\n{\"date\": \"2024-06-30\", \"value\": 1050.0}","handlingStrategy":"validation","validationCode":"clean = []\nfor v in valuations:\n    try:\n        v[\"value\"] = float(v[\"value\"])\n    except (TypeError, ValueError):\n        raise ValueError(f\"non-numeric value at {v!r}\")\n    clean.append(v)","typeGuard":"def is_numeric_value(item: dict) -> bool:\n    try:\n        float(item[\"value\"])\n        return True\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":null,"preventionTips":["Normalize string values (strip $, commas, units) before calling","Prefer JSON numbers over numeric strings in payloads"],"tags":["cashflow-analytics","valuations","type-coercion","python"],"backgroundTag":"numeric-type-coercion-failed","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}