Skip to content

refactor(pass): accept a store factory in Root for lazy keychain init#554

Closed
joe0BAB wants to merge 1 commit into
mainfrom
fix/pass
Closed

refactor(pass): accept a store factory in Root for lazy keychain init#554
joe0BAB wants to merge 1 commit into
mainfrom
fix/pass

Conversation

@joe0BAB

@joe0BAB joe0BAB commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Root previously took a fully-initialized store.Store, which forced the caller to open the OS keychain before cobra had even dispatched the subcommand. On headless systems with no D-Bus session bus this hangs indefinitely (godbus autolaunches dbus-launch, which waits forever), so even docker-pass version and --help are unusable.

Switch Root to take a StoreFactory — a func() (store.Store, error) — and invoke it from each subcommand's RunE. Subcommands that never touch the store (version, help, completion) no longer open the keychain.

@joe0BAB joe0BAB marked this pull request as ready for review June 10, 2026 14:23

@docker-agent docker-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟡 NEEDS ATTENTION

This refactor is well-structured — factory errors are propagated correctly in get, list, and rm, and subcommands that don't need the store (version, help) correctly skip initialization.

One ordering issue was found in set.go where newStore() is called before argument validation, defeating the lazy-init goal for invalid inputs. Verification returned an inconclusive response; the finding is surfaced for author evaluation.

Note: No test covers a factory that returns an error, so the new error-propagation path in all four subcommands is untested.

Comment thread plugins/pass/commands/set.go Outdated
@joe0BAB

joe0BAB commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator Author

/review

Root previously took a fully-initialized store.Store, which forced the
caller to open the OS keychain before cobra had even dispatched the
subcommand. On headless systems with no D-Bus session bus this hangs
indefinitely (godbus autolaunches dbus-launch, which waits forever), so
even `docker-pass version` and `--help` are unusable.

Switch Root to take a StoreFactory — a `func() (store.Store, error)` —
and invoke it from each subcommand's RunE. Subcommands that never touch
the store (version, help, completion) no longer open the keychain.

Signed-off-by: Johannes Großmann <grossmann.johannes@t-online.de>
Comment thread plugins/pass/command_test.go
@joe0BAB joe0BAB closed this Jun 11, 2026
@joe0BAB joe0BAB deleted the fix/pass branch June 11, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant