Graphify-Labs/graphify · error · FileNotFoundError
Graph file not found: {resolved}
Error message
Graph file not found: {resolved} What it means
Raised in _load_graph (graphify/serve.py) when the resolved path has the required .json suffix but no file exists at that location. It is the second-stage existence check, immediately before the size cap and JSON parse, so it means the extension was right but the file itself is missing.
Source
Thrown at graphify/serve.py:31
import networkx as nx
from networkx.readwrite import json_graph
from graphify.security import sanitize_label, check_graph_file_size_cap
from graphify.build import edge_data, edge_datas
from graphify.paths import default_graph_json as _default_graph_json
try:
import jieba as _jieba # type: ignore[import-untyped]
except ImportError:
_jieba = None
def _load_graph(graph_path: str) -> nx.Graph:
try:
resolved = Path(graph_path).resolve()
if resolved.suffix != ".json":
raise ValueError(f"Graph path must be a .json file, got: {graph_path!r}")
if not resolved.exists():
raise FileNotFoundError(f"Graph file not found: {resolved}")
check_graph_file_size_cap(resolved)
safe = resolved
data = json.loads(safe.read_text(encoding="utf-8"))
if "links" not in data and "edges" in data:
data = dict(data, links=data["edges"])
# Stash the on-disk logical flag before the load-time override below:
# `directed: True` exists only so renderers can recover stored arc
# order (#2309); tools that care about logical direction (#2487) must
# not mistake the override for graph truth.
_logical_directed = bool(data.get("directed", False))
data = {**data, "directed": True}
try:
from graphify.build import graph_has_legacy_ids as _legacy
if _legacy(data.get("nodes", [])):
print(
"[graphify] note: this graph uses the pre-#1504 node-ID scheme; "
"rebuild with `graphify extract --force` for path-qualified IDs.",
file=sys.stderr,View on GitHub (pinned to 7fe58b0b0f)
Solutions
- Run /graphify (or the build command) to produce graphify-out/graph.json, then retry.
- Confirm the exact resolved path: Path(graph_path).resolve() — the error prints it; compare against where the file actually is.
- Update the --graph / config path or MCP project_path to the checkout that actually contains graph.json.
- In CI, order the graph-build step before serve/query steps.
Example fix
# before
G = _load_graph("graphify-out/graph.json") # FileNotFoundError: not built yet
# after
subprocess.run(["graphify", "build", "."], check=True)
G = _load_graph("graphify-out/graph.json") Defensive patterns
Strategy: validation
Validate before calling
graph_json = Path(project_root) / "graphify-out" / "graph.json"
if not graph_json.is_file():
raise SystemExit(f"no graph at {graph_json}; run the graph build first") Type guard
def graph_json_ready(project_root: str | Path) -> bool:
return (Path(project_root) / "graphify-out" / "graph.json").is_file() Try / catch
try:
G = _load_graph(path)
except FileNotFoundError as e:
if "Graph file not found" in str(e):
subprocess.run(["graphify", "build", "."], check=True)
G = _load_graph(path)
else:
raise Prevention
- Ensure the build step ran before any load/serve step in scripts and CI.
- Print the resolved path in logs so wrong-cwd failures are obvious.
- Point configs at the exact graph.json file, not a guessed location.
When it happens
Trigger: Calling _load_graph or the serve/CLI entry points with a .json path that does not exist — wrong directory, graph never built (no graphify-out/graph.json yet), or the file was deleted/moved since the path was configured.
Common situations: Serving or querying before running /graphify; stale configured graph_path after output was cleaned; MCP config pointing at another project's checkout; wrong cwd making a relative path resolve elsewhere.
Related errors
- Graph file not found: {resolved}
- Graph base directory does not exist: {base}. Run /graphify f
- Path {path!r} escapes the allowed directory {base}. Only pat
- graph.json not found: {resolved_path}
- file_hash requires a file, got: {p}
AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14).
Data as JSON: /api/errors/5840a5e64f24a030.
Report an issue: GitHub.