{"record":{"id":"dafbd2ea6b69829f","repo":"HKUDS/Vibe-Trading","slug":"run-dcf-capital-structure-basis-must-be-one-of-c","errorCode":null,"errorMessage":"run_dcf: capital_structure_basis must be one of {CAPITAL_STRUCTURE_BASES}, got {capital_structure_basis!r}","messagePattern":"run_dcf: capital_structure_basis must be one of (.+?), got (.+?)","errorType":"validation","errorClass":"ValuationError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/dcf.py","lineNumber":1312,"sourceCode":"            see ``DCFResult.terminal_value``.\n        gdp_growth_ceiling: Reference ceiling used only to flag (never block)\n            ``terminal_growth`` -- see :data:`DEFAULT_LONG_RUN_GDP_GROWTH_CEILING`.\n\n    Returns:\n        A :class:`DCFResult` with every intermediate figure visible.\n\n    Raises:\n        MissingInputError: If any required key is absent from ``inputs``.\n        ValuationError: If ``capital_structure_basis``,\n            ``discounting_convention`` or ``terminal_value_method`` is\n            unrecognised; if ``terminal_growth`` or ``exit_multiple`` is not\n            the matching :class:`Assumption`; if ``terminal_growth.value >=``\n            the built WACC; if any capital-structure, FCFF-bridge or\n            balance-sheet input fails its own guard (see :func:`wacc`,\n            :func:`fcff_bridge`, :func:`terminal_value`, :func:`equity_bridge`).\n    \"\"\"\n    if capital_structure_basis not in CAPITAL_STRUCTURE_BASES:\n        raise ValuationError(\n            f\"run_dcf: capital_structure_basis must be one of \"\n            f\"{CAPITAL_STRUCTURE_BASES}, got {capital_structure_basis!r}\"\n        )\n    if discounting_convention not in DISCOUNTING_CONVENTIONS:\n        raise ValuationError(\n            f\"run_dcf: discounting_convention must be one of \"\n            f\"{DISCOUNTING_CONVENTIONS}, got {discounting_convention!r}\"\n        )\n    if terminal_value_method not in TERMINAL_VALUE_METHODS:\n        raise ValuationError(\n            f\"run_dcf: terminal_value_method must be one of \"\n            f\"{TERMINAL_VALUE_METHODS}, got {terminal_value_method!r}\"\n        )\n\n    structure_fields = (\n        DCF_CURRENT_STRUCTURE_FIELDS\n        if capital_structure_basis == \"current\"\n        else DCF_TARGET_STRUCTURE_FIELDS","sourceCodeStart":1294,"sourceCodeEnd":1330,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/dcf.py#L1294-L1330","documentation":"run_dcf validates its capital_structure_basis enum argument against the module-level CAPITAL_STRUCTURE_BASES set before doing any work. Any value not in that set (e.g. a typo like 'target' instead of 'target_structure') raises ValuationError immediately. This is a fail-fast guard so downstream WACC and equity-bridge math never runs on an undefined basis.","triggerScenarios":"Calling run_dcf(capital_structure_basis=...) with a string not in CAPITAL_STRUCTURE_BASES — misspelled basis name, wrong casing, or passing a different config key's value (e.g. a discounting_convention string).","commonSituations":"Config-driven DCF pipelines where the basis comes from YAML/JSON; refactors that rename basis constants; agents or LLM tool callers guessing enum values.","solutions":["Check the accepted values: from the module import CAPITAL_STRUCTURE_BASES and print it; use one of those exact strings.","Fix the typo/case in the config or call site (values are case-sensitive).","Validate basis against CAPITAL_STRUCTURE_BASES in your config loader before invoking run_dcf."],"exampleFix":"// before\nrun_dcf(base, assumptions, capital_structure_basis=\"target\")  # ValueError\n// after\nfrom quantlib.valuation.dcf import CAPITAL_STRUCTURE_BASES  # e.g. {'current','target'}\nrun_dcf(base, assumptions, capital_structure_basis=\"target_structure\")","handlingStrategy":"validation","validationCode":"from quantlib.valuation.dcf import CAPITAL_STRUCTURE_BASES\nassert capital_structure_basis in CAPITAL_STRUCTURE_BASES, f\"pick from {CAPITAL_STRUCTURE_BASES}\"","typeGuard":"def is_valid_basis(b: str) -> bool:\n    from quantlib.valuation.dcf import CAPITAL_STRUCTURE_BASES\n    return isinstance(b, str) and b in CAPITAL_STRUCTURE_BASES","tryCatchPattern":"try:\n    result = run_dcf(...)\nexcept ValuationError as e:\n    if 'capital_structure_basis' in str(e):\n        log_config_error('basis', e)","preventionTips":["Load enum values from the module constants instead of hardcoding strings","Validate config enums at load time, not at model call time"],"tags":["valuation","dcf","enum-validation","invalid-argument"],"backgroundTag":"enum-value-invalid","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}