HKUDS/Vibe-Trading · error · ValueError
valuations[{index}] must be an object with date and value
Error message
valuations[{index}] must be an object with date and value What it means
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.
Source
Thrown at agent/src/tools/cashflow_analytics_tool.py:324
Args:
raw: Value supplied for the ``valuations`` parameter.
Returns:
Pairs in the order supplied; the library sorts and validates them.
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.
View on GitHub (pinned to 80ffdda44c)
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
Example fix
# before
valuations=list(zip(dates, values)) # [(d, v), ...]
# after
valuations=[{'date': d, 'value': v} for d, v in zip(dates, values)] Defensive patterns
Strategy: type-guard
Validate before calling
assert all(isinstance(i, dict) and {'date','value'} <= i.keys() for i in valuations) Type guard
def entries_are_objects(v: list) -> bool:
return all(isinstance(i, dict) for i in v) Try / catch
try:
tool.execute(valuations=valuations)
except ValueError as e:
if 'must be an object' in str(e):
valuations = [{'date': d, 'value': val} for d, val in v] # reshape rows Prevention
- Use DataFrame.to_dict('records') when converting tabular data
- Never forward zip/tuple rows as JSON arrays
When it happens
Trigger: Calling execute with valuations=['2024-01-01', ...], [[date, value], ...], or mixed arrays where some entries are scalars.
Common situations: Tuple/array-style rows from pandas itertuples or zip; LLM emitting shorthand formats; converting CSVs where each row becomes a list.
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
- valuations must be an array of at least two {date, value} ob
- valuations may contain at most {_MAX_VALUATIONS} entries
- invalid alpha_id
- alpha_id not found
- invalid period: {exc}
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/acca776b5d32d12e.
Report an issue: GitHub.