{"record":{"id":"8171069c1da5ebaf","repo":"HKUDS/Vibe-Trading","slug":"export-three-statement-workbook-expected-a-three","errorCode":null,"errorMessage":"export_three_statement_workbook: expected a 'three_statement' artifact, got {artifact.model_name!r}","messagePattern":"export_three_statement_workbook: expected a 'three_statement' artifact, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/artifact.py","lineNumber":1430,"sourceCode":"    \"Balance Sheet\" (including a ``residual`` column, opening balance sheet\n    plus every period), \"Assumptions & Data Quality\" (see\n    :func:`_write_assumptions_and_gaps_sheet` -- for three-statement this\n    sheet's assumptions block always reads \"(none)\"; see\n    :func:`build_three_statement_artifact`).\n\n    Args:\n        artifact: A ``model_name=\"three_statement\"`` artifact from\n            :func:`build_three_statement_artifact`.\n        path: Output ``.xlsx`` path. Parent directories are created if absent.\n\n    Returns:\n        The written path.\n\n    Raises:\n        TypeError: If ``artifact.model_name != \"three_statement\"``.\n    \"\"\"\n    if artifact.model_name != \"three_statement\":\n        raise TypeError(\n            \"export_three_statement_workbook: expected a 'three_statement' \"\n            f\"artifact, got {artifact.model_name!r}\"\n        )\n    projection: ThreeStatementProjection = artifact.result\n\n    wb = Workbook()\n    wb.remove(wb.active)\n    _write_income_statement_sheet(wb, projection)\n    _write_cash_flow_sheet(wb, projection)\n    _write_balance_sheet_sheet(wb, projection)\n    _write_assumptions_and_gaps_sheet(wb, artifact)\n\n    out_path = Path(path)\n    out_path.parent.mkdir(parents=True, exist_ok=True)\n    wb.save(str(out_path))\n    return out_path\n\n","sourceCodeStart":1412,"sourceCodeEnd":1448,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/artifact.py#L1412-L1448","documentation":"export_three_statement_workbook requires artifact.model_name == 'three_statement' and then treats artifact.result as a ThreeStatementProjection. Other model names fail fast with a TypeError instead of an AttributeError deep inside workbook assembly.","triggerScenarios":"export_three_statement_workbook(dcf_artifact, path); passing a comps artifact; generic export code not branching on model type.","commonSituations":"Shared export helpers reused across model types; template/endpoint mix-ups; renamed model_name values after a refactor.","solutions":["Call the exporter that matches the artifact type.","Dispatch via {model_name: exporter_fn}.","Assert model_name before exporting."],"exampleFix":"# before\nexport_three_statement_workbook(artifact, path)  # artifact.model_name == \"comps\"\n# after\nexport_comps_workbook(artifact, path)  # or dispatch on artifact.model_name","handlingStrategy":"type-guard","validationCode":"if artifact.model_name != \"three_statement\":\n    raise TypeError(f\"not a three_statement artifact: {artifact.model_name!r}\")\nexport_three_statement_workbook(artifact, path)","typeGuard":"def is_three_statement_artifact(a) -> bool:\n    return getattr(a, \"model_name\", None) == \"three_statement\"","tryCatchPattern":null,"preventionTips":["Dispatch exporters by model_name.","Add asserts on model_name in shared export entry points."],"tags":["python","excel","workbook","export","type-validation"],"backgroundTag":"wrong-artifact-type-for-export","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}