HKUDS/Vibe-Trading · error · TypeError
export_dcf_workbook: expected a 'dcf' artifact, got {artifac
Error message
export_dcf_workbook: expected a 'dcf' artifact, got {artifact.model_name!r} What it means
export_dcf_workbook dispatches on artifact.model_name and only accepts 'dcf'. It then assumes artifact.result is a DCFResult when building the Excel workbook, so any other model_name is a TypeError before touching openpyxl.
Source
Thrown at agent/src/quantlib/valuation/artifact.py:1193
value per share), "Sensitivity" (the caller-supplied grid), "Assumptions
& Data Quality" (see :func:`_write_assumptions_and_gaps_sheet`).
Args:
artifact: A ``model_name="dcf"`` artifact from :func:`build_dcf_artifact`.
path: Output ``.xlsx`` path. Parent directories are created if absent.
sensitivity_grid: A wacc x growth value-per-share grid, e.g. from
:func:`src.quantlib.valuation.dcf.sensitivity_grid`. Required --
this function does not choose a WACC/growth sweep range on the
caller's behalf; see the module docstring.
Returns:
The written path.
Raises:
TypeError: If ``artifact.model_name != "dcf"``.
"""
if artifact.model_name != "dcf":
raise TypeError(
f"export_dcf_workbook: expected a 'dcf' artifact, got {artifact.model_name!r}"
)
result: DCFResult = artifact.result
wb = Workbook()
wb.remove(wb.active)
_write_fcff_bridge_sheet(wb, result)
_write_wacc_sheet(wb, result)
_write_terminal_value_sheet(wb, result)
_write_sensitivity_sheet(wb, sensitivity_grid)
_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
- Call export_comps_workbook or export_three_statement_workbook for those model types.
- Route by model_name in a dispatch dict.
- Validate model_name before choosing the exporter.
Example fix
# before
export_dcf_workbook(artifact, path) # artifact.model_name == "comps"
# after
exporters = {"dcf": export_dcf_workbook, "comps": export_comps_workbook,
"three_statement": export_three_statement_workbook}
exporters[artifact.model_name](artifact, path) Defensive patterns
Strategy: type-guard
Validate before calling
if artifact.model_name != "dcf":
raise TypeError(f"not a dcf artifact: {artifact.model_name!r}")
export_dcf_workbook(artifact, path) Type guard
def is_dcf_artifact(a) -> bool:
return getattr(a, "model_name", None) == "dcf" Prevention
- Route exports through a {model_name: exporter} dispatch table.
- Never reuse one model's export call site for another model's artifacts.
When it happens
Trigger: export_dcf_workbook(comps_artifact, path); passing a three_statement artifact; wiring a generic artifact list into a DCF-only export function.
Common situations: Generic export loops/routing tables mapping artifacts to the wrong exporter; UI selecting the wrong workbook template.
Related errors
- export_comps_workbook: expected a 'comps' artifact, got {art
- 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/037f1a0cbf463d16.
Report an issue: GitHub.