{"record":{"id":"6e2ee4fecc37c88b","repo":"HKUDS/Vibe-Trading","slug":"build-comps-artifact-result-must-be-a-compsresult","errorCode":null,"errorMessage":"build_comps_artifact: result must be a CompsResult, got {type(result).__name__}","messagePattern":"build_comps_artifact: result must be a CompsResult, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/artifact.py","lineNumber":808,"sourceCode":"    Args:\n        target: The :class:`TargetCompany` passed to ``run_comps``.\n        peers: The peer sequence passed to ``run_comps``.\n        calendarisation_policy: The ``calendarisation_policy`` the call used.\n        result: The :class:`CompsResult` that call produced.\n        generated_at: Timezone-aware timestamp of the run, supplied by the\n            caller.\n\n    Returns:\n        A ``model_name=\"comps\"`` :class:`ModelArtifact`.\n\n    Raises:\n        TypeError: If ``generated_at`` is not a ``datetime``, or ``result``\n            is not a :class:`CompsResult`.\n        ValueError: If ``generated_at`` is timezone-naive.\n    \"\"\"\n    generated_at = _require_generated_at(generated_at, \"build_comps_artifact\")\n    if not isinstance(result, CompsResult):\n        raise TypeError(\n            f\"build_comps_artifact: result must be a CompsResult, got {type(result).__name__}\"\n        )\n\n    canonical_inputs = {\n        \"config\": {\"calendarisation_policy\": calendarisation_policy},\n        \"target\": target,\n        \"peers\": list(peers),\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] = {}\n    assumptions: list[AssumptionRecord] = []\n    _flatten(result, \"$\", {}, readable_outputs, assumptions)\n\n    return ModelArtifact(","sourceCodeStart":790,"sourceCodeEnd":826,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/artifact.py#L790-L826","documentation":"build_comps_artifact requires result to be a CompsResult instance, mirroring the DCF variant. Anything else (dict, DCFResult, raw multiples table) raises a TypeError before any hashing happens.","triggerScenarios":"build_comps_artifact(result=df_of_multiples, ...); passing the output of run_dcf or a plain dict; feeding a dataclass from an older version of the comps module.","commonSituations":"Model refactor changing run_comps' return type; mixing up build_*_artifact calls when copy-pasting; stale imports shadowing CompsResult.","solutions":["Pass the CompsResult returned by run_comps(...).","Re-export or re-wrap your data into a CompsResult before artifact creation.","Check for duplicate/stale CompsResult definitions on the import path."],"exampleFix":"# before\nbuild_comps_artifact(result=peer_table_df, generated_at=ts)\n# after\nbuild_comps_artifact(result=run_comps(target, peers), generated_at=ts)","handlingStrategy":"type-guard","validationCode":"from quantlib.valuation.models import CompsResult\nassert isinstance(result, CompsResult), f\"expected CompsResult, got {type(result).__name__}\"","typeGuard":"from quantlib.valuation.models import CompsResult\ndef is_comps_result(value) -> bool:\n    return isinstance(value, CompsResult)","tryCatchPattern":null,"preventionTips":["Pass run_comps(...) output straight through.","Check for stale duplicate CompsResult classes after refactors."],"tags":["python","type-validation","artifact","comps"],"backgroundTag":"wrong-argument-type","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}