{"record":{"id":"4a97ca83bb9eff77","repo":"Graphify-Labs/graphify","slug":"graph-base-directory-does-not-exist-base-run","errorCode":null,"errorMessage":"Graph base directory does not exist: {base}. Run /graphify first to build the graph.","messagePattern":"Graph base directory does not exist: (.+?)\\. Run /graphify first to build the graph\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"graphify/security.py","lineNumber":337,"sourceCode":"    Also requires the base directory to exist, so a caller cannot\n    trick graphify into reading files before any graph has been built.\n\n    Raises:\n        ValueError  - path escapes base, or base does not exist\n        FileNotFoundError - resolved path does not exist\n    \"\"\"\n    if base is None:\n        resolved_hint = Path(path).resolve()\n        for candidate in [resolved_hint, *resolved_hint.parents]:\n            if candidate.name == GRAPHIFY_OUT_NAME:\n                base = candidate\n                break\n        if base is None:\n            base = Path(GRAPHIFY_OUT).resolve()\n\n    base = base.resolve()\n    if not base.exists():\n        raise ValueError(\n            f\"Graph base directory does not exist: {base}. \"\n            \"Run /graphify first to build the graph.\"\n        )\n\n    resolved = Path(path).resolve()\n    try:\n        resolved.relative_to(base)\n    except ValueError:\n        raise ValueError(\n            f\"Path {path!r} escapes the allowed directory {base}. \"\n            \"Only paths inside graphify-out/ are permitted.\"\n        )\n\n    if not resolved.exists():\n        raise FileNotFoundError(f\"Graph file not found: {resolved}\")\n\n    return resolved\n","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/Graphify-Labs/graphify/blob/7fe58b0b0f3873be9a21c30106b8b8527c353aa6/graphify/security.py#L319-L355","documentation":"Raised by the graph-path validator in graphify/security.py when the graphify-out/ base directory cannot be found: an optional base argument was given (or auto-discovery by walking parents for a directory named graphify-out, then falling back to the default GRAPHIFY_OUT) and that path does not exist on disk. It tells you the knowledge graph has never been built in this location.","triggerScenarios":"Calling a graph-file helper (e.g. resolve_graph_path) with base=None in a checkout where /graphify has never run, or passing an explicit base= path that does not exist. The check is base.exists() before any per-file validation.","commonSituations":"Fresh clone where the MCP server or CLI is invoked before building the graph; CI job that runs query tools without the graph-build step; wrong working directory so the default graphify-out resolves to a nonexistent location; renamed output directory.","solutions":["Build the graph first: run /graphify (or the graphify build command) in the repository root so graphify-out/ is created.","If the graph lives elsewhere, pass the correct base directory explicitly to the API you are calling.","Confirm the working directory / project path your tool or MCP client sends actually contains graphify-out/.","In CI, add the graph-build step before any step that queries the graph."],"exampleFix":"# before\np = resolve_graph_path(\"graphify-out/graph.json\")  # ValueError: base does not exist\n\n# after\nsubprocess.run([\"graphify\", \"build\", \".\"], check=True)  # creates graphify-out/\np = resolve_graph_path(\"graphify-out/graph.json\")","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef graph_base_ready(root: str | Path) -> bool:\n    base = Path(root) / \"graphify-out\"\n    return base.is_dir() and (base / \"graph.json\").exists()","typeGuard":"def has_graph_output(root: Path) -> bool:\n    return (root / \"graphify-out\").is_dir()","tryCatchPattern":"try:\n    resolved = resolve_graph_path(path)\nexcept ValueError as e:\n    if \"Graph base directory does not exist\" in str(e):\n        subprocess.run([\"graphify\", \"build\", str(project_root)], check=True)\n        resolved = resolve_graph_path(path)\n    else:\n        raise","preventionTips":["Gate graph queries behind a 'graphify-out/ exists' check in setup/CI.","Build the graph as an explicit step before serving or querying.","Pin the correct project root in MCP client configs."],"tags":["filesystem","graph","setup"],"backgroundTag":null,"analyzedSha":"7fe58b0b0f3873be9a21c30106b8b8527c353aa6","analyzedAt":"2026-08-14T19:23:21.323Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}