{"record":{"id":"d10378f44e8378b8","repo":"HKUDS/Vibe-Trading","slug":"flows-must-contain-cashflow-got-type-flow-nam","errorCode":null,"errorMessage":"flows must contain CashFlow, got {type(flow).__name__}","messagePattern":"flows must contain CashFlow, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/cashflow.py","lineNumber":729,"sourceCode":"            ``quote_currency`` becomes the returned series' currency.\n        allow_stale_rates: Forwarded to ``FxRateTable.get_rate``. Off by\n            default, so a settlement date with no exact quote raises rather\n            than silently reusing an older one.\n        max_staleness_days: Forwarded to ``FxRateTable.get_rate``.\n\n    Returns:\n        A ``CashFlowSeries`` with ``pre_translated=True`` and\n        ``currency=rate_table.quote_currency``.\n\n    Raises:\n        MissingExchangeRateError: If a flow's currency has no usable rate for\n            its settlement date; see ``allow_stale_rates``.\n        ValueError: If ``flows`` contains a member that is not a ``CashFlow``.\n    \"\"\"\n    translated: list[CashFlow] = []\n    for flow in flows:\n        if not isinstance(flow, CashFlow):\n            raise ValueError(f\"flows must contain CashFlow, got {type(flow).__name__}\")\n\n        if flow.currency == rate_table.quote_currency:\n            converted_amount = flow.amount\n            rate_used = 1.0\n            rate_date = flow.date\n            is_stale = False\n        else:\n            fx_rate, is_stale = rate_table.get_rate(\n                flow.currency,\n                flow.date,\n                allow_stale=allow_stale_rates,\n                max_staleness_days=max_staleness_days,\n            )\n            converted_amount = flow.amount * fx_rate.rate\n            rate_used = fx_rate.rate\n            rate_date = fx_rate.date\n\n        metadata = dict(flow.metadata)","sourceCodeStart":711,"sourceCodeEnd":747,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/cashflow.py#L711-L747","documentation":"translate_cashflows iterates flows and requires every member to be a CashFlow instance; dicts, tuples, or duck-typed objects fail with the type name before any currency math begins.","triggerScenarios":"table.translate_cashflows([{'amount': 100, 'currency': 'EUR'}, ...]) — raw rows passed instead of entities.","commonSituations":"Piping loader output directly into translation without constructing CashFlow objects; pandas to_dict records; a test using stub objects.","solutions":["Construct CashFlow objects first, then translate","If rows come from a file, run the loader (load_cashflows) that produces entities"],"exampleFix":"# before\ntranslated = table.translate_cashflows(raw_rows)\n# after\nflows = [CashFlow(**r) for r in raw_rows]\ntranslated = table.translate_cashflows(flows)","handlingStrategy":"type-guard","validationCode":"from agent.src.entities.cashflow import CashFlow\nassert all(isinstance(f, CashFlow) for f in flows)","typeGuard":"from agent.src.entities.cashflow import CashFlow\ndef all_cashflows(seq) -> bool:\n    return all(isinstance(f, CashFlow) for f in seq)","tryCatchPattern":"try:\n    table.translate_cashflows(flows)\nexcept ValueError as e:\n    if 'must contain CashFlow' in str(e):\n        flows = [f if isinstance(f, CashFlow) else CashFlow(**f) for f in flows]","preventionTips":["Materialize CashFlow entities at load time","Type-annotate pipelines as Iterable[CashFlow]"],"tags":["python","cashflow","fx-rate","type-validation"],"backgroundTag":"container-type-validation","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}