{"record":{"id":"937d2bf5679e7910","repo":"HKUDS/Vibe-Trading","slug":"flows-index-is-missing-exc-args-0-r","errorCode":null,"errorMessage":"flows[{index}] is missing {exc.args[0]!r}","messagePattern":"flows\\[(.+?)\\] is missing (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/cashflow_analytics_tool.py","lineNumber":397,"sourceCode":"        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:\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    \"\"\"","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/cashflow_analytics_tool.py#L379-L415","documentation":"While constructing a CashFlow from a flow dict, a required key ('date', 'amount', or 'kind') was absent and raised KeyError, which is re-raised with the flow's index and the missing key name. This is a per-row field-level validation failure, distinct from shape/type errors.","triggerScenarios":"flows=[{\"date\": \"2024-01-01\", \"amount\": 100}] missing 'kind'; misspelled keys like \"amt\" or \"Date\" so item[\"amount\"]/item[\"date\"] misses.","commonSituations":"Key casing mismatches between the data source and the tool schema; optional-looking fields omitted in sparse records; LLM tool calls trimming fields it deemed optional.","solutions":["Add the missing key named in the error message (the !r in the message shows exactly which key is absent)","Normalize keys to lowercase {date, amount, kind} before calling"],"exampleFix":"# before\n{\"date\": \"2024-01-01\", \"amount\": 100, \"currency\": \"USD\"}\n# after\n{\"date\": \"2024-01-01\", \"amount\": 100, \"kind\": \"inflow\", \"currency\": \"USD\"}","handlingStrategy":"validation","validationCode":"required = {\"date\", \"amount\", \"kind\"}\nmissing = [i for i, f in enumerate(flows) if not required <= f.keys()]\nif missing:\n    raise ValueError(f\"flows missing required keys at indices {missing}\")","typeGuard":"from typing import TypeGuard\n\ndef is_complete_flow(item: dict) -> TypeGuard[dict]:\n    return {\"date\", \"amount\", \"kind\"} <= item.keys()","tryCatchPattern":"try:\n    result = tool.execute(**kwargs)\nexcept ValueError as exc:\n    if \"is missing\" in str(exc):\n        key = exc.args[0].split(\"'\")[1]  # patch payload and retry\n    raise","preventionTips":["Normalize key casing to lowercase snake_case before calling","Test payload builders against the required-key set"],"tags":["cashflow-analytics","flows","required-field-missing","python"],"backgroundTag":"required-field-missing","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}