Graphify-Labs/graphify · error · RuntimeError

Cannot parse {json_path}: {exc}. The file may be corrupted —

Error message

Cannot parse {json_path}: {exc}. The file may be corrupted — re-run 'graphify extract'.

What it means

Graph-existence preflight in the /graphify explain command of the devin fragment (tools/skillgen/fragments/core/devin.md:1268). Node-explanation traversal loads graphify-out/graph.json; this guard exits 1 with a build-first instruction when the file is missing, before the loader can fail.

Source

Thrown at graphify/diagnostics.py:289

        "post_build_graph_type": graph_type,
        "post_build_node_count": post_build_node_count,
        "post_build_edge_count": post_build_edge_count,
        "post_build_error": build_error,
        "producer_suppression": scan_producer_suppression_sites(suppression_path),
        "examples": examples,
    }


def _read_json_file(path: str | Path) -> dict[str, Any]:
    """Read a JSON graph after applying Graphify's graph-load size cap."""
    from graphify.security import check_graph_file_size_cap

    json_path = Path(path)
    check_graph_file_size_cap(json_path)
    try:
        data = json.loads(json_path.read_text(encoding="utf-8"))
    except (json.JSONDecodeError, OSError) as exc:
        raise RuntimeError(
            f"Cannot parse {json_path}: {exc}. "
            "The file may be corrupted — re-run 'graphify extract'."
        ) from exc
    if not isinstance(data, dict):
        raise ValueError("diagnostic input must be a JSON object")
    return data


def diagnose_file(
    path: str | Path,
    *,
    directed: bool | None = None,
    root: str | Path | None = None,
    max_examples: int = 5,
    extract_path: str | Path | None = None,
) -> dict[str, Any]:
    """Diagnose a graph/extraction JSON file without mutating it.

View on GitHub (pinned to 7fe58b0b0f)

Solutions

  1. Run /graphify <path> first to produce the graph.
  2. Check the working directory contains graphify-out/graph.json.
  3. Repair the failing build step if a previous run never wrote graph.json.
  4. Rebuild after cleanup.

Example fix

# before
/graphify explain middleware
# ERROR: No graph found ...

# after
/graphify .
/graphify explain middleware
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

if not Path('graphify-out/graph.json').is_file():
    raise SystemExit('no graph - run /graphify <path> before explain')
print('ok')

Prevention

When it happens

Trigger: Running /graphify explain <concept> when graphify-out/graph.json is absent from the current working directory — never built, built elsewhere, deleted, or a prior build stopped before the export step.

Common situations: Fresh workspace without a build; cwd mismatch; graphify-out/ cleaned by CI or git clean; build previously aborted (empty extraction / shrink refusal).

Related errors


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