Graphify-Labs/graphify · error · ValueError

Graph base directory does not exist: {base}. Run /graphify f

Error message

Graph base directory does not exist: {base}. Run /graphify first to build the graph.

What it means

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.

Source

Thrown at graphify/security.py:337

    Also requires the base directory to exist, so a caller cannot
    trick graphify into reading files before any graph has been built.

    Raises:
        ValueError  - path escapes base, or base does not exist
        FileNotFoundError - resolved path does not exist
    """
    if base is None:
        resolved_hint = Path(path).resolve()
        for candidate in [resolved_hint, *resolved_hint.parents]:
            if candidate.name == GRAPHIFY_OUT_NAME:
                base = candidate
                break
        if base is None:
            base = Path(GRAPHIFY_OUT).resolve()

    base = base.resolve()
    if not base.exists():
        raise ValueError(
            f"Graph base directory does not exist: {base}. "
            "Run /graphify first to build the graph."
        )

    resolved = Path(path).resolve()
    try:
        resolved.relative_to(base)
    except ValueError:
        raise ValueError(
            f"Path {path!r} escapes the allowed directory {base}. "
            "Only paths inside graphify-out/ are permitted."
        )

    if not resolved.exists():
        raise FileNotFoundError(f"Graph file not found: {resolved}")

    return resolved

View on GitHub (pinned to 7fe58b0b0f)

Solutions

  1. Build the graph first: run /graphify (or the graphify build command) in the repository root so graphify-out/ is created.
  2. If the graph lives elsewhere, pass the correct base directory explicitly to the API you are calling.
  3. Confirm the working directory / project path your tool or MCP client sends actually contains graphify-out/.
  4. In CI, add the graph-build step before any step that queries the graph.

Example fix

# before
p = resolve_graph_path("graphify-out/graph.json")  # ValueError: base does not exist

# after
subprocess.run(["graphify", "build", "."], check=True)  # creates graphify-out/
p = resolve_graph_path("graphify-out/graph.json")
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

def graph_base_ready(root: str | Path) -> bool:
    base = Path(root) / "graphify-out"
    return base.is_dir() and (base / "graph.json").exists()

Type guard

def has_graph_output(root: Path) -> bool:
    return (root / "graphify-out").is_dir()

Try / catch

try:
    resolved = resolve_graph_path(path)
except ValueError as e:
    if "Graph base directory does not exist" in str(e):
        subprocess.run(["graphify", "build", str(project_root)], check=True)
        resolved = resolve_graph_path(path)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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