You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
resolveDbConfig/deriveRootDirFromDbPath derives the wrong rootDir for a --db path outside the <repo>/.codegraph/graph.db convention #2224
Found while reviewing Greptile feedback on #2223. deriveRootDirFromDbPath() (src/db/connection.ts) — the helper resolveDbConfig() uses to derive loadConfig()'s rootDir from a --db path — unconditionally strips exactly two path components:
This assumes every resolved DB path matches the <repo>/.codegraph/graph.db convention. findDbPath() normalizes directory-style --db inputs to that convention, but resolveCustomDbPath() returns an explicit file path as-is when it already exists — so --db /repo/custom.db (a real file, just not named/located per convention) resolves to rootDir /repo/.. = the repo's parent, not /repo.
Confirmed empirically against origin/main (unaffected by #2223 — src/db/connection.ts is untouched there): a project at <tmp>/custom.db with <tmp>/.codegraphrc.json setting db.busyTimeoutMs = 12345, called via the pre-existingmanifestoData() (#1881's original call site, not touched by #2223):
resolveDbConfig(customDbFile).db.busyTimeoutMs // 5000 (DEFAULTS), not 12345
So this affects every resolveDbConfig() consumer equally — both #1881's original six call sites and #2017/#2223's newly-migrated ones — whenever --db points at a real, non-conventionally-named/located database file rather than a directory or <repo>/.codegraph/graph.db itself.
Fix direction
deriveRootDirFromDbPath needs to detect whether the resolved path actually ends in .codegraph/graph.db (or .codegraph/<file>) before stripping two levels — for any other file layout, it should probably walk up from the file's directory looking for .codegraphrc.json/.git, mirroring findRepoRoot()'s own logic, rather than assuming a fixed depth.
Scope
Out of scope for #2223 (which only extends resolveDbConfig's existing usage to more call sites) and out of scope for the original #1881 (which introduced the helper) — this is a defect in the helper itself, shared by every consumer. Filed separately per the project's one-concern-per-PR convention.
Activity