{"record":{"id":"2ff4c01c3da04721","repo":"HKUDS/Vibe-Trading","slug":"build-dcf-artifact-result-must-be-a-dcfresult-go","errorCode":null,"errorMessage":"build_dcf_artifact: result must be a DCFResult, got {type(result).__name__}","messagePattern":"build_dcf_artifact: result must be a DCFResult, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/artifact.py","lineNumber":735,"sourceCode":"        result: The :class:`DCFResult` that call produced.\n        generated_at: Timezone-aware timestamp of the run, supplied by the\n            caller. See :func:`_require_generated_at`.\n        capital_structure_basis: The ``capital_structure_basis`` the call used.\n        discounting_convention: The ``discounting_convention`` the call used.\n        terminal_value_method: The ``terminal_value_method`` the call used.\n        gdp_growth_ceiling: The ``gdp_growth_ceiling`` the call used.\n\n    Returns:\n        A ``model_name=\"dcf\"`` :class:`ModelArtifact`.\n\n    Raises:\n        TypeError: If ``generated_at`` is not a ``datetime``, or ``result``\n            is not a :class:`DCFResult`.\n        ValueError: If ``generated_at`` is timezone-naive.\n    \"\"\"\n    generated_at = _require_generated_at(generated_at, \"build_dcf_artifact\")\n    if not isinstance(result, DCFResult):\n        raise TypeError(\n            f\"build_dcf_artifact: result must be a DCFResult, got {type(result).__name__}\"\n        )\n\n    canonical_inputs = {\n        \"config\": {\n            \"capital_structure_basis\": capital_structure_basis,\n            \"discounting_convention\": discounting_convention,\n            \"terminal_value_method\": terminal_value_method,\n            \"gdp_growth_ceiling\": gdp_growth_ceiling,\n        },\n        \"model_inputs\": dict(inputs),\n    }\n    hash_leaves: dict[str, str] = {}\n    readable_inputs: dict[str, Any] = {}\n    _flatten(canonical_inputs, \"$\", hash_leaves, readable_inputs, None)\n    input_hash = _hash_leaves(hash_leaves)\n\n    readable_outputs: dict[str, Any] = {}","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/artifact.py#L717-L753","documentation":"build_dcf_artifact requires its result argument to be a DCFResult instance so the artifact's outputs are typed and diffable. Passing anything else (dict, DataFrame, a result from another model) is a TypeError.","triggerScenarios":"build_dcf_artifact(result=some_dict, ...); passing a CompsResult or the raw outputs of run_dcf instead of the DCFResult dataclass; passing a namedtuple that mimics the fields.","commonSituations":"Refactoring the DCF engine to return dicts while artifact code still expects the dataclass; copy-pasting artifact build calls across models; duck-typed test doubles.","solutions":["Pass the DCFResult produced by the DCF engine (e.g. run_dcf(...) return value).","If you changed the result shape, wrap it back into a DCFResult before building the artifact.","For duck-typed substitutes, subclass or register against DCFResult (it must pass isinstance)."],"exampleFix":"# before\nbuild_dcf_artifact(result={\"ev\": 1_000_000}, generated_at=ts)\n# after\nbuild_dcf_artifact(result=run_dcf(model, assumptions), generated_at=ts)","handlingStrategy":"type-guard","validationCode":"from quantlib.valuation.models import DCFResult\nif not isinstance(result, DCFResult):\n    raise TypeError(f\"expected DCFResult, got {type(result).__name__}\")","typeGuard":"from quantlib.valuation.models import DCFResult\ndef is_dcf_result(value) -> bool:\n    return isinstance(value, DCFResult)","tryCatchPattern":null,"preventionTips":["Thread the engine's return value directly into build_dcf_artifact.","Don't reshape results into dicts between engine and artifact."],"tags":["python","type-validation","artifact","dcf"],"backgroundTag":"wrong-argument-type","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}