HKUDS/Vibe-Trading · error · TypeError
export_comps_workbook: expected a 'comps' artifact, got {art
Error message
export_comps_workbook: expected a 'comps' artifact, got {artifact.model_name!r} What it means
export_comps_workbook only accepts artifacts whose model_name is 'comps'; it casts artifact.result to CompsResult and writes the comps workbook. Any other model_name raises a TypeError up front.
Source
Thrown at agent/src/quantlib/valuation/artifact.py:1314
Sheets, in order: "Peer Detail", "Multiple Matrix" (including the
excluded-peer detail block), "Implied Valuation", "Assumptions & Data
Quality" (see :func:`_write_assumptions_and_gaps_sheet` -- for comps this
sheet's assumptions block always reads "(none)"; see
:func:`build_comps_artifact`).
Args:
artifact: A ``model_name="comps"`` artifact from :func:`build_comps_artifact`.
path: Output ``.xlsx`` path. Parent directories are created if absent.
Returns:
The written path.
Raises:
TypeError: If ``artifact.model_name != "comps"``.
"""
if artifact.model_name != "comps":
raise TypeError(
f"export_comps_workbook: expected a 'comps' artifact, got {artifact.model_name!r}"
)
result: CompsResult = artifact.result
wb = Workbook()
wb.remove(wb.active)
_write_peer_detail_sheet(wb, result)
_write_multiple_matrix_sheet(wb, result)
_write_implied_valuation_sheet(wb, result)
_write_assumptions_and_gaps_sheet(wb, artifact)
out_path = Path(path)
out_path.parent.mkdir(parents=True, exist_ok=True)
wb.save(str(out_path))
return out_path
# ---------------------------------------------------------------------------View on GitHub (pinned to 80ffdda44c)
Solutions
- Use the exporter matching the artifact's model_name.
- Dispatch on model_name (dict of exporters).
- Rename/route checks before export.
Example fix
# before export_comps_workbook(artifact, path) # artifact.model_name == "dcf" # after export_dcf_workbook(artifact, path) # or dispatch on artifact.model_name
Defensive patterns
Strategy: type-guard
Validate before calling
if artifact.model_name != "comps":
raise TypeError(f"not a comps artifact: {artifact.model_name!r}")
export_comps_workbook(artifact, path) Type guard
def is_comps_artifact(a) -> bool:
return getattr(a, "model_name", None) == "comps" Prevention
- Dispatch exporters by model_name.
- Keep export functions model-specific; don't write generic wrappers that guess.
When it happens
Trigger: export_comps_workbook(dcf_artifact, path); feeding a three_statement artifact; a routing table pointing all artifacts at the comps exporter.
Common situations: Copy-pasted export call sites; generic export menus; refactored model_name strings after a rename.
Related errors
- export_dcf_workbook: expected a 'dcf' artifact, got {artifac
- export_three_statement_workbook: expected a 'three_statement
- amount must be numeric, got {self.amount!r}
- metadata must be a mapping, got {type(self.metadata).__name_
- CashFlowSeries members must be CashFlow, got {type(item).__n
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/259ad8629b4140d7.
Report an issue: GitHub.