HKUDS/Vibe-Trading · error · ValueError
flows[{index}] must be an object
Error message
flows[{index}] must be an object What it means
Each element of the inline flows array must be a dict/mapping. Encountering a string, number, list, or null element raises this indexed error before field extraction.
Source
Thrown at agent/src/tools/cashflow_analytics_tool.py:380
str(path),
columns=columns,
currency=currency,
default_kind=kwargs.get("flows_default_kind"),
date_format=kwargs.get("flows_date_format"),
invert_sign=bool(kwargs.get("flows_invert_sign", False)),
)
if not inline:
return None
if not isinstance(inline, list):
raise ValueError("flows must be an array of {date, amount, kind} objects")
if len(inline) > _MAX_INLINE_FLOWS:
raise ValueError(f"flows may contain at most {_MAX_INLINE_FLOWS} entries")
records: list[CashFlow] = []
for index, item in enumerate(inline):
if not isinstance(item, dict):
raise ValueError(f"flows[{index}] must be an object")
row_currency = item.get("currency") or currency
if not row_currency:
raise ValueError(
f"flows[{index}] has no currency and no top-level currency was "
"given; currency is never defaulted"
)
try:
records.append(
CashFlow(
date=item["date"],
amount=item["amount"],
kind=item["kind"],
currency=row_currency,
)
)
except KeyError as exc:
raise ValueError(f"flows[{index}] is missing {exc.args[0]!r}") from exc
except ValueError as exc:View on GitHub (pinned to 80ffdda44c)
Solutions
- Map each row to a dict: {"date": r[0], "amount": r[1], "kind": r[2]}
- Filter out null/empty elements before calling
Example fix
# before
flows = [("2024-01-01", 100, "inflow")]
# after
flows = [{"date": d, "amount": a, "kind": k} for d, a, k in rows] Defensive patterns
Strategy: type-guard
Validate before calling
flows = [f for f in flows if isinstance(f, dict)]
# or convert tuple/list rows:
flows = [{"date": r[0], "amount": r[1], "kind": r[2]} for r in rows] Type guard
from typing import TypeGuard
def is_flow_item(item: object) -> TypeGuard[dict]:
return isinstance(item, dict) Prevention
- Convert DB cursor tuples / CSV rows to dicts at the boundary
- Drop null elements before calling
When it happens
Trigger: flows=["2024-01-01,100,inflow"] (array of CSV strings), flows=[None], flows=[123], or flows=[["2024-01-01", 100, "inflow"]] (arrays instead of objects).
Common situations: Passing raw CSV lines or tuple rows from a database cursor without converting to dicts; JSON arrays of arrays; sparse data with null holes.
Related errors
- flows must be an array of {date, amount, kind} objects
- flows_columns must be an object mapping field to column name
- flows may contain at most {_MAX_INLINE_FLOWS} entries
- flows[{index}] is missing {exc.args[0]!r}
- amount must be numeric, got {self.amount!r}
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/ff7be21f69d2d2a0.
Report an issue: GitHub.