CLI ignores --data-dir for the store: repo policy/wal/compact/import read and write the default store #611
Labels
No labels
actions
bug
cli
duplicate
enhancement
fork
forum
git storage
help wanted
insights
invalid
issues
moderation
oidc
ownership transfer
packages
pr/merge protection rules
projects
pull requests
question
releases
sponsorships
tags
webhooks
wiki
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
crueber/walhub#611
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Evidence (live field test, scratch stack :18099, throwaway repo field/demo)
walhub --data-dir /tmp/field-data repo policy set --file policy.json field/demoexits 0 but writes to~/.local/share/walhub/store/…(the ResolveDataDir default), not /tmp/field-data/store. Proven:--data-dir /tmp/does-not-exist-xyz repo policy getstill returns the doc (flag provably ignored);config dump --data-dir /tmp/field-dataprintsstore.root = /home/crueber/.local/share/walhub/store.conflict: required-reviews: need 1 approvals, have 0).Mechanism (static read)
config.Loadresolves its working data dir fromResolveDataDir(getenv)(env/defaults only); the peeled--data-dirflag (c.dataDir) is never threaded in. Candidates come fromdefaultConfigPaths(c)(flag-aware), but with no file presentFirstRunDefaultsuses the env-resolved dir — so Store.Root/Cache.Dir point at the default store.serverepairs this with the flag-sync fixup (serve.go:63-69 — re-points flag-derived Store.Root/Cache.Dir, preserving explicit file values and the env overlay). The CLI path (openEngine→dataDirFor+openStore, which prefers cfg.Store.Root) has no such sync, so every CLI subcommand (repo policy/settings, wal, compact, bundle, import, repo create, config dump/check) operates on the wrong store whenever --data-dir differs from the default.WALHUB_DATA_DIR=/tmp/field-data) works correctly — only the flag is dropped.What's requested
Apply the serve-style flag sync (flag-derived DataDir/Store.Root/Cache.Dir only, explicit file values and env overlay preserved) in the shared CLI path (
resolveConfigoropenEngine) so all subcommands honor --data-dir. Serve's fixup becomes redundant but harmless (idempotent).Acceptance criteria
--data-dir X repo policy set/get,config dump, and the other store-touching subcommands all operate under X (proven with a nonexistent X failing/empty rather than leaking to the default).Fixed by #614 (merged): shared syncDataDirFlag in resolveConfig re-points flag-derived DataDir/Store.Root/Cache.Dir (explicit file values + WALHUB__* overlay preserved); serve fixup kept as idempotent no-op. Verified: matrix red-on-main/green-on-fix, cmd/config suites -race green, live-binary proof (no default leak), independent review APPROVE.