{"record":{"id":"829b1de39184efab","repo":"HKUDS/Vibe-Trading","slug":"flow-timing-must-be-flow-timing-end-r-or-flow-t","errorCode":null,"errorMessage":"flow_timing must be {FLOW_TIMING_END!r} or {FLOW_TIMING_START!r}, got {raw!r}","messagePattern":"flow_timing must be (.+?) or (.+?), got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/cashflow_analytics_tool.py","lineNumber":420,"sourceCode":"\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\n    token = str(raw).strip().lower()\n    if token not in (FLOW_TIMING_END, FLOW_TIMING_START):\n        raise ValueError(\n            f\"flow_timing must be {FLOW_TIMING_END!r} or {FLOW_TIMING_START!r}, \"\n            f\"got {raw!r}\"\n        )\n    return token\n\n\ndef _coerce_kinds(raw: Any, field_name: str) -> list[str] | None:\n    \"\"\"Validate an optional kind-classification override.\n\n    Args:\n        raw: Value supplied for ``external_kinds`` or ``internal_kinds``.\n        field_name: Name used in the error message.\n\n    Returns:\n        The list of labels, or ``None`` to keep the module default.\n\n    Raises:\n        ValueError: If the value is not an array of non-empty strings.","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/cashflow_analytics_tool.py#L402-L438","documentation":"The `flow_timing` option must be exactly one of the two recognized tokens (end or start), after stripping and lowercasing. Any other non-empty value is rejected because cashflow timing conventions change computed results (end-of-period vs start-of-period discounting).","triggerScenarios":"Passing flow_timing='beginning', 'END ' (ok, lowercased), 'middle', 'e', or an arbitrary string to the tool's execute(); only ''/None and the two exact tokens (case-insensitive) are accepted.","commonSituations":"Callers copy terminology from other finance libraries (e.g. numpy-financial's 'beginning'/'end'); LLM agents guess the enum; config files carry a stale token from an older version.","solutions":["Set flow_timing to 'end' or 'start' (case-insensitive), or omit it / pass '' to default to 'end'","If the value comes from user config, validate it against the allowed set before invoking the tool"],"exampleFix":"# before\nresult = execute(flows=flows, flow_timing=\"beginning\")\n# after\nresult = execute(flows=flows, flow_timing=\"start\")  # 'beginning' maps to 'start'","handlingStrategy":"type-guard","validationCode":"ALLOWED = {\"end\", \"start\"}\ndef norm_timing(v):\n    if v is None:\n        return \"end\"\n    t = str(v).strip().lower()\n    assert t in ALLOWED, f\"flow_timing must be one of {ALLOWED}, got {v!r}\"\n    return t","typeGuard":"def is_flow_timing(v) -> bool:\n    return v is None or (isinstance(v, str) and (not v.strip() or v.strip().lower() in {\"end\", \"start\"}))","tryCatchPattern":"try:\n    execute(flows=flows, flow_timing=timing)\nexcept ValueError as exc:\n    if \"flow_timing must be\" in str(exc):\n        execute(flows=flows, flow_timing=\"end\")  # safe default\n    else:\n        raise","preventionTips":["Keep the allowed tokens ('end'/'start') in one constant reused by callers and UI validation","Map external vocabulary (e.g. 'beginning'->'start') at your boundary","Omit the argument entirely when the default end-of-period is acceptable"],"tags":["validation","enum","cashflow","python"],"backgroundTag":"invalid-enum-value","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}