{"record":{"id":"05a23d76c0e6895c","repo":"tirth8205/code-review-graph","slug":"the-graph-holds-len-file-paths-file-s-such-as","errorCode":null,"errorMessage":"the graph holds {len(file_paths)} file(s) such as {sample!r}, none of them under {str(repo_root)!r}; it was built with a different repository root. Rebuild it, or retry with the root it was built with, instead of reconciling every file away.","messagePattern":"the graph holds (.+?) file\\(s\\) such as (.+?), none of them under (.+?); it was built with a different repository root\\. Rebuild it, or retry with the root it was built with, instead of reconciling every file away\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"code_review_graph/incremental.py","lineNumber":1128,"sourceCode":"\n\ndef _assert_graph_matches_root(repo_root: Path, store: GraphStore) -> None:\n    \"\"\"Refuse an incremental reconciliation anchored to a different root.\n\n    Authoritative File nodes identify the root a graph was built with. If none\n    of them are under the requested root, treating every row as stale is more\n    likely to destroy a usable graph than to clean up orphan rows. Orphan-only\n    databases have no File markers and retain the purge behavior from #861.\n    \"\"\"\n    file_paths = store.get_file_marker_paths()\n    if not file_paths:\n        return\n    prefix = normalize_file_path(repo_root)\n    prefix = prefix if prefix.endswith(\"/\") else prefix + \"/\"\n    if any(normalize_file_path(path).startswith(prefix) for path in file_paths):\n        return\n    sample = normalize_file_path(sorted(file_paths)[0])\n    raise RuntimeError(\n        f\"the graph holds {len(file_paths)} file(s) such as {sample!r}, none of \"\n        f\"them under {str(repo_root)!r}; it was built with a different \"\n        \"repository root. Rebuild it, or retry with the root it was built \"\n        \"with, instead of reconciling every file away.\"\n    )\n\n\n_MAX_DEPENDENT_HOPS = int(os.environ.get(\"CRG_DEPENDENT_HOPS\", \"2\"))\n_MAX_DEPENDENT_FILES = 500\n\n\ndef _single_hop_dependents(store: GraphStore, file_path: str) -> set[str]:\n    \"\"\"Find files that directly depend on *file_path* (single hop).\"\"\"\n    dependents: set[str] = set()\n    edges = store.get_edges_by_target(file_path)\n    for e in edges:\n        if e.kind == \"IMPORTS_FROM\":\n            dependents.add(e.file_path)","sourceCodeStart":1110,"sourceCodeEnd":1146,"githubUrl":"https://github.com/tirth8205/code-review-graph/blob/b58668751ab0c7670c078cf7cbd4d1f5b8e54f81/code_review_graph/incremental.py#L1110-L1146","documentation":"incremental_update reconciles stored file paths against repo_root; if none of the stored files share the root's normalized prefix, it assumes the graph belongs to a different repository and aborts rather than reconciling every file away (which would empty the graph).","triggerScenarios":"Running incremental_update(repo_root=X) when the graph was built under root Y — e.g. the repo moved, was cloned to a new path, or you passed the wrong root.","commonSituations":"Moving/cloning the project to a different directory, symlinks changing effective paths, or CI checking out to a different workspace path than where the index was built.","solutions":["Re-run with the original root the graph was built with (shown in the message)","Or rebuild the graph from scratch under the new root","If the move is permanent, delete the old graph db and re-index"],"exampleFix":"# before\nincremental_update(store, repo_root=\"/new/home/proj\")\n# after\nincremental_update(store, repo_root=\"/old/home/proj\")  # or rebuild index at new root","handlingStrategy":"validation","validationCode":"stored = {normalize_file_path(p) for p in graph_store.all_file_paths()}\nprefix = normalize_file_path(repo_root).rstrip(\"/\") + \"/\"\nif stored and not any(p.startswith(prefix) for p in stored):\n    raise RuntimeError(\"graph root mismatch; rebuild or pass original root\")","typeGuard":null,"tryCatchPattern":"try:\n    incremental_update(store, repo_root=root)\nexcept RuntimeError as e:\n    if \"different repository root\" in str(e):\n        rebuild_index(root)  # full rebuild at the new root\n    else:\n        raise","preventionTips":["Persist the build-time repo root in the index metadata and compare before incremental updates","Re-index after moving/cloning a repo to a new path","Avoid symlink-only roots that change effective paths"],"tags":["incremental-update","path-mismatch","repo-root"],"backgroundTag":"path-resolution-mismatch","analyzedSha":"b58668751ab0c7670c078cf7cbd4d1f5b8e54f81","analyzedAt":"2026-08-28T13:19:08.966Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}