{"record":{"id":"5840a5e64f24a030","repo":"Graphify-Labs/graphify","slug":"graph-file-not-found-resolved-5840a5","errorCode":null,"errorMessage":"Graph file not found: {resolved}","messagePattern":"Graph file not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"graphify/serve.py","lineNumber":31,"sourceCode":"import networkx as nx\nfrom networkx.readwrite import json_graph\nfrom graphify.security import sanitize_label, check_graph_file_size_cap\nfrom graphify.build import edge_data, edge_datas\nfrom graphify.paths import default_graph_json as _default_graph_json\n\ntry:\n    import jieba as _jieba  # type: ignore[import-untyped]\nexcept ImportError:\n    _jieba = None\n\n\ndef _load_graph(graph_path: str) -> nx.Graph:\n    try:\n        resolved = Path(graph_path).resolve()\n        if resolved.suffix != \".json\":\n            raise ValueError(f\"Graph path must be a .json file, got: {graph_path!r}\")\n        if not resolved.exists():\n            raise FileNotFoundError(f\"Graph file not found: {resolved}\")\n        check_graph_file_size_cap(resolved)\n        safe = resolved\n        data = json.loads(safe.read_text(encoding=\"utf-8\"))\n        if \"links\" not in data and \"edges\" in data:\n            data = dict(data, links=data[\"edges\"])\n        # Stash the on-disk logical flag before the load-time override below:\n        # `directed: True` exists only so renderers can recover stored arc\n        # order (#2309); tools that care about logical direction (#2487) must\n        # not mistake the override for graph truth.\n        _logical_directed = bool(data.get(\"directed\", False))\n        data = {**data, \"directed\": True}\n        try:\n            from graphify.build import graph_has_legacy_ids as _legacy\n            if _legacy(data.get(\"nodes\", [])):\n                print(\n                    \"[graphify] note: this graph uses the pre-#1504 node-ID scheme; \"\n                    \"rebuild with `graphify extract --force` for path-qualified IDs.\",\n                    file=sys.stderr,","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/Graphify-Labs/graphify/blob/7fe58b0b0f3873be9a21c30106b8b8527c353aa6/graphify/serve.py#L13-L49","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nG = _load_graph(\"graphify-out/graph.json\")  # FileNotFoundError: not built yet\n\n# after\nsubprocess.run([\"graphify\", \"build\", \".\"], check=True)\nG = _load_graph(\"graphify-out/graph.json\")","handlingStrategy":"validation","validationCode":"graph_json = Path(project_root) / \"graphify-out\" / \"graph.json\"\nif not graph_json.is_file():\n    raise SystemExit(f\"no graph at {graph_json}; run the graph build first\")","typeGuard":"def graph_json_ready(project_root: str | Path) -> bool:\n    return (Path(project_root) / \"graphify-out\" / \"graph.json\").is_file()","tryCatchPattern":"try:\n    G = _load_graph(path)\nexcept FileNotFoundError as e:\n    if \"Graph file not found\" in str(e):\n        subprocess.run([\"graphify\", \"build\", \".\"], check=True)\n        G = _load_graph(path)\n    else:\n        raise","preventionTips":["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."],"tags":["graph","missing-file","filesystem"],"backgroundTag":null,"analyzedSha":"7fe58b0b0f3873be9a21c30106b8b8527c353aa6","analyzedAt":"2026-08-14T19:23:21.323Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}