HKUDS/Vibe-Trading · error · TypeError
build_comps_artifact: result must be a CompsResult, got
Error message
build_comps_artifact: result must be a CompsResult, got {type(result).__name__} What it means
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.
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.
Example fix
# before build_comps_artifact(result=peer_table_df, generated_at=ts) # after build_comps_artifact(result=run_comps(target, peers), generated_at=ts)
Defensive patterns
Strategy: type-guard
Validate before calling
from quantlib.valuation.models import CompsResult
assert isinstance(result, CompsResult), f"expected CompsResult, got {type(result).__name__}" Type guard
from quantlib.valuation.models import CompsResult
def is_comps_result(value) -> bool:
return isinstance(value, CompsResult) Prevention
- Pass run_comps(...) output straight through.
- Check for stale duplicate CompsResult classes after refactors.
When it happens
Trigger: 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.
Common situations: Model refactor changing run_comps' return type; mixing up build_*_artifact calls when copy-pasting; stale imports shadowing CompsResult.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- build_dcf_artifact: result must be a DCFResult, got
- build_three_statement_artifact: result must be a…
- : generated_at must be a datetime.datetime supplied by the…
- amount must be numeric, got
- artifact: cannot normalize a value of type
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/6e2ee4fecc37c88b.
Report an issue: GitHub.
Appendix: source
Thrown at agent/src/quantlib/valuation/artifact.py:808
Args:
target: The :class:`TargetCompany` passed to ``run_comps``.
peers: The peer sequence passed to ``run_comps``.
calendarisation_policy: The ``calendarisation_policy`` the call used.
result: The :class:`CompsResult` that call produced.
generated_at: Timezone-aware timestamp of the run, supplied by the
caller.
Returns:
A ``model_name="comps"`` :class:`ModelArtifact`.
Raises:
TypeError: If ``generated_at`` is not a ``datetime``, or ``result``
is not a :class:`CompsResult`.
ValueError: If ``generated_at`` is timezone-naive.
"""
generated_at = _require_generated_at(generated_at, "build_comps_artifact")
if not isinstance(result, CompsResult):
raise TypeError(
f"build_comps_artifact: result must be a CompsResult, got {type(result).__name__}"
)
canonical_inputs = {
"config": {"calendarisation_policy": calendarisation_policy},
"target": target,
"peers": list(peers),
}
hash_leaves: dict[str, str] = {}
readable_inputs: dict[str, Any] = {}
_flatten(canonical_inputs, "$", hash_leaves, readable_inputs, None)
input_hash = _hash_leaves(hash_leaves)
readable_outputs: dict[str, Any] = {}
assumptions: list[AssumptionRecord] = []
_flatten(result, "$", {}, readable_outputs, assumptions)
return ModelArtifact(View on GitHub (pinned to 80ffdda44c)