fix(cli): keep repo .beads config when dolt_data_dir escapes#2614
fix(cli): keep repo .beads config when dolt_data_dir escapes#2614garitar wants to merge 3 commits intosteveyegge:mainfrom
Conversation
|
Quick CI note:
So after the formatting-only follow-up, the remaining red appears to be upstream/background rather than caused by the |
|
Canary follow-up: I just pushed The functional fix still held, but the regression harness had one portability problem: it was hardcoded to build Focused validation:
|
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
DreadPirateRobertz
left a comment
There was a problem hiding this comment.
Good catch — the filepath.Dir(dbPath) assumption breaks when dolt_data_dir escapes .beads. The fix to resolve the owning .beads directory independently from the Dolt data path is the right approach.
The test case (TestListUsesRepoBeadsDirWhenDoltDataDirEscapesDotBeads) is well-constructed — it exercises the exact failure path with an external data dir, seeded port file, and verifiable issue.
Summary
While auditing #2590 and PR #2591, I found a remaining failing case in the normal CLI path: when
metadata.jsonsetsdolt_data_diroutside.beads,bd listderives the wrong config directory fromfilepath.Dir(dbPath), loses the repo-local port/database config, and can fall back to the wrong server.This patch fixes that by resolving the owning
.beadsdirectory independently from the discovered Dolt data path before loading config and opening the store.Fixes #2590.
Why this is different from #2591
PR #2591 improves
applyConfigDefaults(), but the failingbd listpath incmd/bd/main.gowas already callingdoltserver.DefaultConfig(beadsDir). The real bug was thatbeadsDiritself was wrong wheneverdolt_data_direscaped.beads.So this PR addresses a narrower but load-bearing CLI failure mode:
dbPathpoints at the external Dolt data dirfilepath.Dir(dbPath)is no longer the repo's.beadsconfigfile.Load(beadsDir)missesmetadata.json,dolt-server.port, and the configured database nameProof Repro
Added
TestListUsesRepoBeadsDirWhenDoltDataDirEscapesDotBeadsincmd/bd/main_test.go.It creates a repo with:
.beads/metadata.jsonsettingdolt_data_dir = ../external-dolt.beads/dolt-server.portThen it runs a real
bd list --jsonsubprocess.Behavior:
origin/main, the repro fails becausebd listloses the repo config, hits the wrong port under fallback behavior, auto-starts a shadow server, and cannot find the configured database.Test Plan
go test ./cmd/bd -run '^TestListUsesRepoBeadsDirWhenDoltDataDirEscapesDotBeads$' -count=1 -vgo test ./cmd/bd -run '^(TestBlockedEnvVars|TestListUsesRepoBeadsDirWhenDoltDataDirEscapesDotBeads)$' -count=1go test ./cmd/bd -run '^(TestImportOpenToClosedTransition|TestImportClosedToOpenTransition|TestBlockedEnvVars|TestListUsesRepoBeadsDirWhenDoltDataDirEscapesDotBeads)$' -count=1Notes
Thanks to #2591 for narrowing the search area. I left a cross-link there as well so maintainers can compare the two failure modes directly.