{"record":{"id":"33c1093546f6e300","repo":"HKUDS/Vibe-Trading","slug":"flows-index-exc","errorCode":null,"errorMessage":"flows[{index}]: {exc}","messagePattern":"flows\\[(.+?)\\]: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/cashflow_analytics_tool.py","lineNumber":399,"sourceCode":"        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:\n            raise ValueError(f\"flows[{index}]: {exc}\") from exc\n    return CashFlowSeries(tuple(records))\n\n\ndef _coerce_flow_timing(raw: Any) -> str:\n    \"\"\"Validate the flow-timing token.\n\n    Args:\n        raw: Value supplied for ``flow_timing``; ``None`` selects the default.\n\n    Returns:\n        Either :data:`~src.quantlib.performance.FLOW_TIMING_END` or\n        :data:`~src.quantlib.performance.FLOW_TIMING_START`.\n\n    Raises:\n        ValueError: If the token is not one of the two recognised values.\n    \"\"\"\n    if raw is None or raw == \"\":\n        return FLOW_TIMING_END","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/cashflow_analytics_tool.py#L381-L417","documentation":"Raised while converting each element of the `flows` argument into a CashFlow record: the per-flow dict either lacks a required key (KeyError wrapped as \"flows[i] is missing 'field'\") or one of its values fails conversion (e.g. a bad date or non-numeric amount), and the inner ValueError is re-raised prefixed with the flow's index. It is a tool-input schema validation error surfaced by the `execute` method.","triggerScenarios":"Calling the cashflow analytics tool with flows=[{...}] where a dict is missing a required key (e.g. no 'date' or 'amount'), or has a malformed value that raises ValueError inside the record constructor/coercion helpers.","commonSituations":"LLM/agent generates a flow dict with a typo'd or omitted field; callers build flows from pandas rows with NaN or missing columns; upstream data source drops optional-looking fields.","solutions":["Inspect the error suffix: 'is missing X' names the absent key, otherwise the inner message names the bad value — fix flows[index] accordingly","Log/pretty-print the offending flows[index] payload before retrying","Add a pre-flight schema check that every flow dict contains the required keys with valid types before calling the tool"],"exampleFix":"// before\ntool.execute(flows=[{\"amount\": 100.0}])  # missing date -> flows[0] is missing 'date'\n// after\ntool.execute(flows=[{\"date\": \"2024-01-15\", \"amount\": 100.0, \"currency\": \"USD\"}])","handlingStrategy":"validation","validationCode":"REQUIRED = {\"date\", \"amount\", \"currency\"}\ndef valid_flows(flows):\n    for i, f in enumerate(flows):\n        missing = REQUIRED - set(f)\n        if missing:\n            return False, f\"flows[{i}] missing {missing}\"\n        if not isinstance(f[\"amount\"], (int, float)) or isinstance(f[\"amount\"], bool):\n            return False, f\"flows[{i}].amount must be numeric\"\n    return True, \"\"","typeGuard":"from typing import Any, TypedDict\n\nclass Flow(TypedDict, total=False):\n    date: str\n    amount: float\n    currency: str\n\ndef is_flow(x: Any) -> bool:\n    return (\n        isinstance(x, dict)\n        and isinstance(x.get(\"date\"), str)\n        and isinstance(x.get(\"amount\"), (int, float))\n        and not isinstance(x.get(\"amount\"), bool)\n    )","tryCatchPattern":"try:\n    result = tool.execute(flows=flows)\nexcept ValueError as exc:\n    if exc.args[0].startswith(\"flows[\"):\n        idx = int(exc.args[0].split(\"[\")[1].split(\"]\")[0])\n        log.warning(\"bad flow %d: %r -> %r\", idx, exc.args[0], flows[idx])\n        flows.pop(idx)  # or repair\n        result = tool.execute(flows=flows)\n    else:\n        raise","preventionTips":["Define a TypedDict/dataclass for flow rows and construct them explicitly instead of passing raw dicts","Validate flows against the required-key set before calling execute","When mapping from DataFrames, use df.dropna(subset=required) first"],"tags":["validation","cashflow","input-schema","python"],"backgroundTag":"missing-required-field","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}