{"record":{"id":"f72658de76c93447","repo":"tirth8205/code-review-graph","slug":"no-graph-found-at-db-path-run-code-review-grap","errorCode":null,"errorMessage":"No graph found at {db_path}. Run `code-review-graph build` first.","messagePattern":"No graph found at (.+?)\\. Run `code-review-graph build` first\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"code_review_graph/cli.py","lineNumber":1395,"sourceCode":"        return\n\n    if args.command in _GRAPH_TOOL_COMMANDS:\n        from .incremental import find_project_root, get_db_path\n\n        if args.repo:\n            # For an explicit --repo the walk must treat .code-review-graph\n            # as a project boundary too: the plain .git/.svn walk resolves a\n            # registered monorepo subdirectory to the monorepo root and the\n            # graph built at the --repo path is never found (#697). Nearest\n            # marker wins, so pointing inside a repo still works.\n            repo_root = _find_explicit_repo_root(Path(args.repo).expanduser())\n            if repo_root is None:\n                print(\n                    f\"--repo does not look like a project root (no .git, .svn, \"\n                    f\"or .code-review-graph found at or above): {args.repo}\",\n                    file=sys.stderr,\n                )\n                raise SystemExit(1)\n        else:\n            repo_root = find_project_root()\n        db_path = get_db_path(repo_root)\n        if not db_path.exists():\n            print(\n                f\"No graph found at {db_path}. Run `code-review-graph build` first.\",\n                file=sys.stderr,\n            )\n            raise SystemExit(1)\n        _run_graph_tool_command(args, repo_root)\n        return\n\n    embedding_refresh_kwargs = _embedding_refresh_kwargs(args, ap)\n\n    if args.command in (\"serve\", \"mcp\"):\n        from .main import main as serve_main\n\n        auto_watch = getattr(args, \"auto_watch\", False)","sourceCodeStart":1377,"sourceCodeEnd":1413,"githubUrl":"https://github.com/tirth8205/code-review-graph/blob/b58668751ab0c7670c078cf7cbd4d1f5b8e54f81/code_review_graph/cli.py#L1377-L1413","documentation":"The CLI commands that operate on an existing knowledge graph require a prebuilt graph database. Before running, main() resolves the repo root and checks that the graph DB file exists; if it does not, it prints this message and exits with code 1. The graph must be created with `code-review-graph build` before query/serve commands can work.","triggerScenarios":"Running any graph-dependent subcommand (query, serve, mcp, review tools, etc.) in a repository where `code-review-graph build` has never been executed, or where the DB path resolution points somewhere without the .code-review-graph database. Also triggered when --repo points at a directory that is not the intended project root.","commonSituations":"Fresh clone of a repo (graph DB is not committed), CI pipelines that assume the graph exists, running the command from a subdirectory so find_project_root() resolves to an unexpected parent, or specifying a wrong --repo path.","solutions":["Run `code-review-graph build` in the repository root to generate the graph DB","Verify you are in the correct repository root (or pass --repo /path/to/project) so get_db_path() resolves to where the graph was built","If the build directory was deleted (e.g. by clean/gitignore rules), rebuild it and consider persisting it in CI caches"],"exampleFix":"# before\n$ code-review-graph query \"login flow\"\nNo graph found at /repo/.code-review-graph/graph.db. Run `code-review-graph build` first.\n\n# after\n$ code-review-graph build\n$ code-review-graph query \"login flow\"","handlingStrategy":"validation","validationCode":"import subprocess, sys\nfrom pathlib import Path\n\ndef graph_exists(repo: Path) -> bool:\n    # mirror get_db_path: DB lives under .code-review-graph in the project root\n    return any((repo / \".code-review-graph\").rglob(\"*.db\")) or (repo / \".code-review-graph\").exists()\n\nif not graph_exists(Path.cwd()):\n    subprocess.run([sys.executable, \"-m\", \"code_review_graph\", \"build\"], check=True)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `code-review-graph build` as part of project bootstrap and CI setup","Persist/cache the .code-review-graph directory in CI between runs","Invoke the CLI from the project root or always pass --repo explicitly"],"tags":["cli","missing-artifact","build-required","exit-code-1"],"backgroundTag":"missing-prerequisite-artifact","analyzedSha":"b58668751ab0c7670c078cf7cbd4d1f5b8e54f81","analyzedAt":"2026-08-28T13:19:08.966Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}