Graphify-Labs/graphify · error · SystemExit

ERROR: Graph is empty - extraction produced no nodes.

Error message

ERROR: Graph is empty - extraction produced no nodes.

What it means

Identical empty-graph guard to skill.md's, but in the generated artifact tools/skillgen/expected/graphify__skill-aider.md (the 'aider' host render of the graphify skill). The Step 4 build block checks G.number_of_nodes() immediately after build_from_json() and SystemExits before any persistence write, protecting existing graph.json / report / analysis from being clobbered by an empty extraction (#1392). This older expected-render variant reads .graphify_extract.json from the working directory and writes the sidecar as .graphify_analysis.json.

Source

Thrown at tools/skillgen/expected/graphify__skill-aider.md:412

$(cat graphify-out/.graphify_python) -c "
import sys, json
from graphify.build import build_from_json
from graphify.cluster import cluster, score_all
from graphify.analyze import god_nodes, surprising_connections, suggest_questions
from graphify.report import generate
from graphify.export import to_json
from pathlib import Path

extraction = json.loads(Path('.graphify_extract.json').read_text())
detection  = json.loads(Path('.graphify_detect.json').read_text())

G = build_from_json(extraction, directed=IS_DIRECTED)
# Guard BEFORE any write: an empty extraction must not clobber a good graph.json /
# GRAPH_REPORT.md / analysis sidecar. Check immediately after build (#1392).
if G.number_of_nodes() == 0:
    print('ERROR: Graph is empty - extraction produced no nodes.')
    print('Possible causes: all files were skipped, binary-only corpus, or extraction failed.')
    raise SystemExit(1)
communities = cluster(G)
cohesion = score_all(G, communities)
tokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}
gods = god_nodes(G)
surprises = surprising_connections(G, communities)
labels = {cid: 'Community ' + str(cid) for cid in communities}
# Placeholder questions - regenerated with real labels in Step 5
questions = suggest_questions(G, communities, labels)

# Persist the graph first and only write the report/analysis if it actually
# persisted - to_json refuses to shrink an existing graph.json (#479), and a
# report describing a graph we did not write would be a lie (#1392).
wrote = to_json(G, communities, 'graphify-out/graph.json')
if not wrote:
    print('ERROR: refused to shrink graphify-out/graph.json (fewer nodes than the existing graph). Run a full rebuild to be safe.')
    raise SystemExit(1)
report = generate(G, communities, cohesion, labels, gods, surprises, detection, tokens, 'INPUT_PATH', suggested_questions=questions)
Path('graphify-out/GRAPH_REPORT.md').write_text(report)

View on GitHub (pinned to 7fe58b0b0f)

Solutions

  1. Re-run the extraction step (Step 3) for the intended path and verify .graphify_extract.json contains nodes/entities
  2. Verify the input directory contains extractable text/code files and .graphifyignore is not excluding everything
  3. Delete a truncated .graphify_extract.json and re-extract from scratch
Defensive patterns

Strategy: validation

Validate before calling

extraction = json.loads(Path('.graphify_extract.json').read_text())
if not extraction.get('nodes') and not extraction.get('entities'):
    raise SystemExit('extraction produced nothing — re-run Step 3 before building')
G = build_from_json(extraction, directed=IS_DIRECTED)

Type guard

def extraction_has_nodes(extraction: dict) -> bool:
    return bool(extraction.get('nodes') or extraction.get('entities'))

Prevention

When it happens

Trigger: Executing the aider skill's Step 4 when the loaded .graphify_extract.json yields zero nodes — all files skipped by ignore rules, binary-only corpus, or a failed/truncated extraction JSON.

Common situations: Running the aider-rendered skill on an empty or fully-ignored directory; stale extract JSON from a different input path; LLM extraction returned nothing but still wrote the file.

Related errors


AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14). Data as JSON: /api/errors/5a9a2f2c8efe66dc. Report an issue: GitHub.