{"record":{"id":"6a33cff28e8d02ae","repo":"tirth8205/code-review-graph","slug":"graph-is-empty-nothing-to-export","errorCode":null,"errorMessage":"Graph is empty, nothing to export","messagePattern":"Graph is empty, nothing to export","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"code_review_graph/exports.py","lineNumber":391,"sourceCode":"    import networkx as nx\n\n    data = export_graph_data(store)\n    nodes_data = data[\"nodes\"]\n    edges_data = data[\"edges\"]\n\n    nxg: nx.DiGraph = nx.DiGraph()  # type: ignore[type-arg]\n    for n in nodes_data:\n        nxg.add_node(\n            n[\"qualified_name\"],\n            label=n.get(\"name\", \"\"),\n            kind=n.get(\"kind\", \"\"),\n        )\n    for e in edges_data:\n        if e[\"source\"] in nxg and e[\"target\"] in nxg:\n            nxg.add_edge(e[\"source\"], e[\"target\"])\n\n    if nxg.number_of_nodes() == 0:\n        raise ValueError(\"Graph is empty, nothing to export\")\n\n    # Color by kind\n    kind_colors = {\n        \"File\": \"#6c757d\",\n        \"Class\": \"#0d6efd\",\n        \"Function\": \"#198754\",\n        \"Type\": \"#ffc107\",\n        \"Test\": \"#dc3545\",\n    }\n    colors = [\n        kind_colors.get(\n            nxg.nodes[n].get(\"kind\", \"\"), \"#adb5bd\"\n        )\n        for n in nxg.nodes()\n    ]\n\n    fig, ax = plt.subplots(1, 1, figsize=(16, 12))\n    pos = nx.spring_layout(","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/tirth8205/code-review-graph/blob/b58668751ab0c7670c078cf7cbd4d1f5b8e54f81/code_review_graph/exports.py#L373-L409","documentation":"export_svg() builds a networkx graph from stored nodes/edges and refuses to render when zero nodes survive — drawing an empty graph is meaningless and usually signals wrong filters or a wrong database.","triggerScenarios":"Calling export_svg() on an empty graph store, or when all nodes are filtered out before export (edges to missing nodes are also dropped).","commonSituations":"Exporting before indexing anything, pointing at a fresh/wrong .db, or filter conditions that exclude every node.","solutions":["Run the indexer to populate the graph first","Check you're reading the correct database file","Relax or fix any node filters applied before export"],"exampleFix":"# before\nexport_svg(empty_store, out.svg)\n# after\n# build the graph first, then:\nexport_svg(populated_store, out.svg)","handlingStrategy":"validation","validationCode":"count = graph_store.node_count() if hasattr(graph_store, \"node_count\") else len(list(graph_store.get_all_nodes()))\nif count == 0:\n    raise RuntimeError(\"graph empty; index the repo before exporting\")","typeGuard":"def graph_is_exportable(store) -> bool:\n    return len(list(store.get_all_nodes())) > 0","tryCatchPattern":"try:\n    export_svg(store, path)\nexcept ValueError as e:\n    if \"nothing to export\" in str(e):\n        log.warning(\"skip export; graph is empty\")\n    else:\n        raise","preventionTips":["Check node count before export","Run the indexer and verify it indexed >0 files before exporting","Validate the db path points at the populated index"],"tags":["svg-export","empty-graph","validation"],"backgroundTag":"empty-result-validation","analyzedSha":"b58668751ab0c7670c078cf7cbd4d1f5b8e54f81","analyzedAt":"2026-08-28T13:19:08.966Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}