Graphify-Labs/graphify · error · SystemExit

ERROR: invalid JSON in {path}: {exc}

Error message

ERROR: invalid JSON in {path}: {exc}

What it means

The empty-graph fail-fast guard in the core graphify skill fragment (tools/skillgen/fragments/core/core.md:354). It prints both the 'Graph is empty' line and the 'Possible causes' line, then raises SystemExit(1) immediately after build_from_json() — before cluster/score/export run — so an empty extraction cannot overwrite a healthy graph.json, GRAPH_REPORT.md, or analysis sidecar (#1392).

Source

Thrown at graphify/callflow_html.py:104

@media (max-width: 768px) { .container { padding: 16px; } h1 { font-size: 1.8rem; } }
"""


# ──────────────────────────────────────────────
# 2. Data loading and normalization helpers
# ──────────────────────────────────────────────

def read_json(path: str | Path, default=None):
    """Read JSON with a useful error message."""
    if not path:
        return default
    path = Path(path)
    if not path.exists():
        return default
    try:
        return json.loads(path.read_text(encoding="utf-8"))
    except json.JSONDecodeError as exc:
        raise SystemExit(f"ERROR: invalid JSON in {path}: {exc}") from exc


def first_present(mapping: dict, *keys, default=None):
    """Return the first non-empty value for any candidate key."""
    for key in keys:
        if key in mapping and mapping[key] not in (None, ""):
            return mapping[key]
    return default


def first_list(*values) -> list:
    """Return the first list from a set of possible schema locations."""
    for value in values:
        if isinstance(value, list):
            return value
    return []

View on GitHub (pinned to 7fe58b0b0f)

Solutions

  1. Verify graphify-out/.graphify_extract.json has nodes; if empty, re-run the extraction stage.
  2. Review .graphify_detect.json to see which files were skipped and correct skip rules or the input path.
  3. Clear .graphify_extract.json/.graphify_detect.json and re-run the full build to rule out stale empty sidecars.
  4. Check the extraction step's token accounting (input_tokens/output_tokens) and logs for a silent upstream failure.

Example fix

# before
/graphify ./docs-pdf-only
# ERROR: Graph is empty - extraction produced no nodes.

# after
rm graphify-out/.graphify_extract.json graphify-out/.graphify_detect.json
/graphify ./src
Defensive patterns

Strategy: validation

Validate before calling

import json
from pathlib import Path

extract = json.loads(Path('graphify-out/.graphify_extract.json').read_text(encoding='utf-8'))
if not (extract.get('nodes') or []):
    raise SystemExit('extraction empty - check skip rules / corpus before build')

Prevention

When it happens

Trigger: build_from_json(extraction, root='INPUT_PATH', directed=IS_DIRECTED) yields G.number_of_nodes() == 0 because .graphify_extract.json contains no nodes: every file skipped, binary-only corpus, or upstream extraction failure.

Common situations: Corpus of images/binaries/lockfiles with no extractable symbols; skip patterns (vendor/, dist/, node_modules misclassified) excluding everything; extraction API call failed on quota/auth but wrote an empty JSON; wrong INPUT_PATH (empty dir).

Understand the failure class

Related errors


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