HKUDS/Vibe-Trading · error · ValueError
valuations[{index}].value must be numeric
Error message
valuations[{index}].value must be numeric What it means
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.
Source
Thrown at agent/src/tools/cashflow_analytics_tool.py:330
Raises:
ValueError: If the array is missing, wrongly shaped, over the size cap,
or an entry lacks a usable date or value.
"""
if not isinstance(raw, list) or len(raw) < 2:
raise ValueError("valuations must be an array of at least two {date, value} objects")
if len(raw) > _MAX_VALUATIONS:
raise ValueError(f"valuations may contain at most {_MAX_VALUATIONS} entries")
pairs: list[tuple[date, float]] = []
for index, item in enumerate(raw):
if not isinstance(item, dict):
raise ValueError(f"valuations[{index}] must be an object with date and value")
if "date" not in item or "value" not in item:
raise ValueError(f"valuations[{index}] needs both 'date' and 'value'")
try:
value = float(item["value"])
except (TypeError, ValueError) as exc:
raise ValueError(f"valuations[{index}].value must be numeric") from exc
if not math.isfinite(value):
raise ValueError(f"valuations[{index}].value must be finite")
pairs.append((item["date"], value))
return pairs
def _resolve_flows(kwargs: dict[str, Any]) -> CashFlowSeries | None:
"""Build the cash-flow series from inline records or from a file.
Args:
kwargs: The tool's raw inputs.
Returns:
A ``CashFlowSeries``, or ``None`` when no flows were supplied.
Raises:
ValueError: If both sources were given, an inline record is malformed,
or a currency is missing. File problems surface asView on GitHub (pinned to 80ffdda44c)
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
Example fix
// before
{"date": "2024-06-30", "value": "1,050.00 USD"}
// after
{"date": "2024-06-30", "value": 1050.0} Defensive patterns
Strategy: validation
Validate before calling
clean = []
for v in valuations:
try:
v["value"] = float(v["value"])
except (TypeError, ValueError):
raise ValueError(f"non-numeric value at {v!r}")
clean.append(v) Type guard
def is_numeric_value(item: dict) -> bool:
try:
float(item["value"])
return True
except (TypeError, ValueError):
return False Prevention
- Normalize string values (strip $, commas, units) before calling
- Prefer JSON numbers over numeric strings in payloads
When it happens
Trigger: valuations=[{"date": "2024-01-01", "value": "abc"}], value=None (TypeError from float(None)), or a string containing a non-numeric character.
Common situations: 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.
Related errors
- valuations[{index}] needs both 'date' and 'value'
- valuations[{index}].value must be finite
- invalid period: {exc}
- pass either flows or flows_path, not both
- flows_columns must be an object mapping field to column name
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/747bf6c2f67e6917.
Report an issue: GitHub.