Graphify-Labs/graphify · error · ValueError

diagnostic input must be a JSON object

Error message

diagnostic input must be a JSON object

What it means

Graph-existence preflight in the shared query reference (tools/skillgen/fragments/references/query/default.md:18), used by /graphify query before any BFS/DFS work. A Python one-liner raises SystemExit(1) with this message when graphify-out/graph.json is missing; the skill then instructs the agent to stop and tell the user to run /graphify <path> first.

Source

Thrown at graphify/diagnostics.py:294

        "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.

    When `directed` is None, the JSON's "directed" flag is honored. Raw
    extraction JSON that has no "directed" flag defaults to directed analysis.
    """
    data = _read_json_file(path)
    if directed is None:

View on GitHub (pinned to 7fe58b0b0f)

Solutions

  1. Run /graphify <path> against the codebase, wait for a successful build, then re-run the query.
  2. Confirm the relative path graphify-out/graph.json resolves from the current working directory.
  3. If the previous build failed, fix its root cause (empty extraction or shrink refusal) — no graph was written.
  4. Treat cleanup tools that delete graphify-out/ as invalidating all graph queries until a rebuild.

Example fix

# before
/graphify query "where is rate limiting applied?"
# ERROR: No graph found ...

# after
/graphify .
/graphify query "where is rate limiting applied?"
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

if not Path('graphify-out/graph.json').is_file():
    print('ERROR: No graph found - run /graphify <path> first; aborting query flow.')
    raise SystemExit(1)
print('graph present - proceed to Step 0 vocabulary extraction')

Prevention

When it happens

Trigger: Executing the query flow (including its Step 0 constrained query expansion, which reads the graph vocabulary) when graphify-out/graph.json does not exist in the current directory — never built, cleaned, wrong cwd, or a build that exited before export.

Common situations: Asking graph questions on a fresh clone; agent running from a subdirectory while the graph lives at repo root; CI cleanup removing graphify-out/; an earlier build failing at the empty-graph or shrink guard so graph.json was never persisted.

Related errors


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