{"record":{"id":"a21f34c8968730cb","repo":"Graphify-Labs/graphify","slug":"error-graph-is-empty-extraction-produced-no-nod-a21f34","errorCode":null,"errorMessage":"ERROR: Graph is empty - extraction produced no nodes.","messagePattern":"ERROR: Graph is empty - extraction produced no nodes\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"tools/skillgen/expected/graphify__skill-copilot.md","lineNumber":419,"sourceCode":"from graphify.build import build_from_json\nfrom graphify.cluster import cluster, score_all\nfrom graphify.analyze import god_nodes, surprising_connections, suggest_questions\nfrom graphify.report import generate\nfrom graphify.export import to_json\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text(encoding=\\\"utf-8\\\"))\ndetection  = json.loads(Path('graphify-out/.graphify_detect.json').read_text(encoding=\\\"utf-8\\\"))\n\n# root= mirrors the --update runbook (#1361): relativize source_file to the same\n# base so the full build and incremental --update never drift apart on re-extract.\nG = build_from_json(extraction, root='INPUT_PATH', directed=IS_DIRECTED)\n# Guard BEFORE any write: an empty extraction must not clobber a good graph.json /\n# GRAPH_REPORT.md / analysis sidecar. Check immediately after build (#1392).\nif G.number_of_nodes() == 0:\n    print('ERROR: Graph is empty - extraction produced no nodes.')\n    print('Possible causes: all files were skipped, binary-only corpus, or extraction failed.')\n    raise SystemExit(1)\ncommunities = cluster(G)\ncohesion = score_all(G, communities)\ntokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}\ngods = god_nodes(G)\nsurprises = surprising_connections(G, communities)\nlabels = {cid: 'Community ' + str(cid) for cid in communities}\n# Placeholder questions - regenerated with real labels in Step 5\nquestions = suggest_questions(G, communities, labels)\n\n# Export FIRST and honor the #479 shrink-guard: to_json returns False (writing\n# nothing) when the new graph is smaller than the existing graph.json. Only write\n# GRAPH_REPORT.md + the analysis sidecar when the graph was actually written, so\n# they never describe a graph that graph.json doesn't contain (#1392).\nwrote = to_json(G, communities, 'graphify-out/graph.json')\nif not wrote:\n    print('ERROR: refused to shrink graphify-out/graph.json (existing graph has more nodes; #479).')\n    print('If this shrink is intentional (you deleted files), re-run a full build with --force.')\n    raise SystemExit(1)","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/Graphify-Labs/graphify/blob/7fe58b0b0f3873be9a21c30106b8b8527c353aa6/tools/skillgen/expected/graphify__skill-copilot.md#L401-L437","documentation":"An explicit fail-fast guard (#1392) in the graphify build pipeline: immediately after build_from_json() reconstructs the graph from graphify-out/.graphify_extract.json, the script checks G.number_of_nodes() == 0 and aborts with SystemExit(1) before any write. Its purpose is to stop an empty extraction from clobbering a good graph.json, GRAPH_REPORT.md, or the analysis sidecar.","triggerScenarios":"build_from_json(extraction, root='INPUT_PATH', directed=IS_DIRECTED) returning a graph with zero nodes — i.e. .graphify_extract.json contains no extractable nodes. The snippet itself lists the causes: all files were skipped, the corpus is binary-only, or the extraction step failed.","commonSituations":"Extraction API/LLM call failed and wrote an empty/partial extract file; input path contains only images, lockfiles, or other skipped file types; ignore/skip rules accidentally matched every file; wrong INPUT_PATH (empty dir); reading the extract with a mismatched root so every source_file relativization drops out.","solutions":["Open graphify-out/.graphify_extract.json and confirm whether it contains any nodes at all — if empty, the failure is in the extraction step, not here.","Verify INPUT_PATH points at a directory with readable text/code files and matches the path used during extraction.","Check the extraction step's skip/ignore configuration (binary extensions, ignore globs) to see if it filtered out everything.","Re-run the extraction step, then re-run this build step; the guard has left any previous good graph.json untouched."],"exampleFix":"# before: guard fires, build aborts\nG = build_from_json(extraction, root='INPUT_PATH', directed=IS_DIRECTED)\nif G.number_of_nodes() == 0:\n    print('ERROR: Graph is empty - extraction produced no nodes.')\n    raise SystemExit(1)\n\n# after: diagnose upstream before re-running the build\nimport json\nfrom pathlib import Path\next = json.loads(Path('graphify-out/.graphify_extract.json').read_text(encoding='utf-8'))\nprint('files seen by extractor:', len(ext.get('files', [])))\nprint('nodes extracted:', sum(len(f.get('nodes', [])) for f in ext.get('files', [])))","handlingStrategy":"validation","validationCode":"import json\nfrom pathlib import Path\n\nextract_path = Path('graphify-out/.graphify_extract.json')\nassert extract_path.exists(), 'extraction sidecar missing - run the extraction step first'\nextraction = json.loads(extract_path.read_text(encoding='utf-8'))\nfiles = extraction.get('files', [])\nassert files and any(f.get('nodes') for f in files), \\\n    'extraction produced no nodes - check skip rules, input path, and extractor logs before building'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the extraction sidecar is non-empty before invoking the build step.","Run extraction and build against the same input root so relativization never drops nodes.","Log the file count and skip count from extraction so a silent all-skipped run is visible.","Confirm the input directory contains text/code files, not only binaries or ignored types."],"tags":["graphify","extraction","empty-graph","fail-fast","build"],"backgroundTag":null,"analyzedSha":"7fe58b0b0f3873be9a21c30106b8b8527c353aa6","analyzedAt":"2026-08-14T19:23:21.323Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}