Repository navigation
fix(cli): bound the keyring availability probe - #5348
Open
shunxinyi-ljs wants to merge 2 commits into
Open
shunxinyi-ljs wants to merge 2 commits into
shunxinyi-ljs wants to merge 2 commits into
Conversation
NewBestEffortStore probes the OS keyring before every command. On a host where the secret service exists but never answers (locked GNOME keyring waiting for the unlock prompt, a DBus socket that accepts and stalls) that Get blocks forever, so commands such as 'weknora config view' or 'weknora doctor --offline' produce no output at all. Give the probe a two-second budget and fall back to the file store, which is a working credential store on those hosts.
shunxinyi-ljs
marked this pull request as ready for review
November 10, 2026 05:18
The probe goroutine reads keyringGet when it starts. When the probe times out, NewBestEffortStore returns before the goroutine has read the seam, so the test cleanup that restores keyringGet raced with that read (reported by -race on all three platforms). Close the goroutine lifecycle instead: the fake seam signals when it returns and the cleanup waits for that signal before restoring the seam. The fake also drops its unused parameter names so revive stops flagging them.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
NewBestEffortStoreprobes the OS keyring with a no-opGetbefore the CLI can read credentials, and that probe has no bound. On a host where the secret service exists but does not answer (locked GNOME keyring waiting for its unlock prompt; a DBus socket that accepts and stalls), the call did not return:weknora config viewandweknora doctor --offlineproduced no output and were still running when killed after 10 s. Both commands are supposed to answer from local state only.The file store already works on those hosts, so waiting longer buys nothing. The probe now runs in a goroutine with a 2 s budget and falls back to
NewFileStore()on timeout. Its result is still the only thing that decides between keyring and file store.Behavior change worth knowing: on an unusable-keyring host, commands that previously hung now continue with the file store.
Type of Change
Related Issue
None.
Testing
Baseline
26723dca, WSL Ubuntu 24.04 where/run/user/0/busexists but never answers:timeout -s KILL 10 ./weknora config view→ no output, rc=137.timeout -s KILL 10 ./weknora doctor --offline→ no output, rc=137.DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/nonexistent-bus.sock ./weknora config view→ returns in 1.3 s, which pins the probe (not the command) as the blocker.With the patch on the same host:
config view→ rc=0 in 3.9 s, reporting"secrets":"file …".go test ./internal/secrets/... -count=1— pass.go test ./cmd/config ./cmd/doctor -count=1— pass; these two used to time out on this host.TestNewBestEffortStoreFallsBackWhenTheProbeHangssubstitutes a probe that blocks forever and asserts the file store is returned. On the baseline it cannot run because the probe seam is what the patch adds.Checklist
git diff --check origin/main...HEADpasses(full
go build ./...needs a cgo vector-store build this machine cannot complete; package-scoped checks were used instead)