{"record":{"id":"ff7be21f69d2d2a0","repo":"HKUDS/Vibe-Trading","slug":"flows-index-must-be-an-object","errorCode":null,"errorMessage":"flows[{index}] must be an object","messagePattern":"flows\\[(.+?)\\] must be an object","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/cashflow_analytics_tool.py","lineNumber":380,"sourceCode":"            str(path),\n            columns=columns,\n            currency=currency,\n            default_kind=kwargs.get(\"flows_default_kind\"),\n            date_format=kwargs.get(\"flows_date_format\"),\n            invert_sign=bool(kwargs.get(\"flows_invert_sign\", False)),\n        )\n\n    if not inline:\n        return None\n    if not isinstance(inline, list):\n        raise ValueError(\"flows must be an array of {date, amount, kind} objects\")\n    if len(inline) > _MAX_INLINE_FLOWS:\n        raise ValueError(f\"flows may contain at most {_MAX_INLINE_FLOWS} entries\")\n\n    records: list[CashFlow] = []\n    for index, item in enumerate(inline):\n        if not isinstance(item, dict):\n            raise ValueError(f\"flows[{index}] must be an object\")\n        row_currency = item.get(\"currency\") or currency\n        if not row_currency:\n            raise ValueError(\n                f\"flows[{index}] has no currency and no top-level currency was \"\n                \"given; currency is never defaulted\"\n            )\n        try:\n            records.append(\n                CashFlow(\n                    date=item[\"date\"],\n                    amount=item[\"amount\"],\n                    kind=item[\"kind\"],\n                    currency=row_currency,\n                )\n            )\n        except KeyError as exc:\n            raise ValueError(f\"flows[{index}] is missing {exc.args[0]!r}\") from exc\n        except ValueError as exc:","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/cashflow_analytics_tool.py#L362-L398","documentation":"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.","triggerScenarios":"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).","commonSituations":"Passing raw CSV lines or tuple rows from a database cursor without converting to dicts; JSON arrays of arrays; sparse data with null holes.","solutions":["Map each row to a dict: {\"date\": r[0], \"amount\": r[1], \"kind\": r[2]}","Filter out null/empty elements before calling"],"exampleFix":"# before\nflows = [(\"2024-01-01\", 100, \"inflow\")]\n# after\nflows = [{\"date\": d, \"amount\": a, \"kind\": k} for d, a, k in rows]","handlingStrategy":"type-guard","validationCode":"flows = [f for f in flows if isinstance(f, dict)]\n# or convert tuple/list rows:\nflows = [{\"date\": r[0], \"amount\": r[1], \"kind\": r[2]} for r in rows]","typeGuard":"from typing import TypeGuard\n\ndef is_flow_item(item: object) -> TypeGuard[dict]:\n    return isinstance(item, dict)","tryCatchPattern":null,"preventionTips":["Convert DB cursor tuples / CSV rows to dicts at the boundary","Drop null elements before calling"],"tags":["cashflow-analytics","flows","type-validation","python"],"backgroundTag":"wrong-parameter-type","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}