{"record":{"id":"9e70bd3638aaf2d3","repo":"HKUDS/Vibe-Trading","slug":"flows-must-be-an-array-of-date-amount-kind-obj","errorCode":null,"errorMessage":"flows must be an array of {date, amount, kind} objects","messagePattern":"flows must be an array of (.+?) objects","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/cashflow_analytics_tool.py","lineNumber":373,"sourceCode":"    currency = kwargs.get(\"currency\")\n\n    if path:\n        columns = kwargs.get(\"flows_columns\")\n        if columns is not None and not isinstance(columns, dict):\n            raise ValueError(\"flows_columns must be an object mapping field to column name\")\n        return load_cashflows(\n            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\"],","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/cashflow_analytics_tool.py#L355-L391","documentation":"Raised when inline flows is present but not a Python list. The tool requires flows to be an array of {date, amount, kind} objects; dicts, strings, or single objects are rejected so parsing stays unambiguous.","triggerScenarios":"execute(flows={\"date\": \"2024-01-01\", ...}) — a single flow object instead of a one-element list; flows=\"2024-01-01,100,inflow\"; flows=(flow1,) tuple.","commonSituations":"Wrapping logic that assumes a single record; JSON where the flows key holds an object instead of an array; passing a generator/tuple from Python code.","solutions":["Wrap single records in a list: flows=[flow]","Ensure JSON payloads use an array for the flows key"],"exampleFix":"# before\nflows=flow_dict\n# after\nflows=[flow_dict]","handlingStrategy":"type-guard","validationCode":"if \"flows\" in kwargs and not isinstance(kwargs[\"flows\"], list):\n    kwargs[\"flows\"] = [kwargs[\"flows\"]] if isinstance(kwargs[\"flows\"], dict) else kwargs[\"flows\"]","typeGuard":"from typing import TypeGuard\n\ndef is_flow_list(v: object) -> TypeGuard[list[dict]]:\n    return isinstance(v, list)","tryCatchPattern":null,"preventionTips":["Always wrap single flow records in a list","Keep the flows JSON key as an array"],"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"}