feat(config): read Bridge password from PM_CLI_BRIDGE_PASSWORD env var - #14
Conversation
Headless servers (no desktop session) often lack a D-Bus secret service, so keyring.Get fails with "org.freedesktop.secrets was not provided by any .service files." GetPassword now consults the PM_CLI_BRIDGE_PASSWORD environment variable before falling back to the system keyring. The variable takes precedence and is only used when set and non-empty, so interactive users are unaffected. Because the value carries the credential itself, no configured email is required on the env-var path. Closes bscott#8 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Reviewed and verified locally against The change itself is right: env var takes precedence, only when non-empty, and the `c.Bridge.Email == """ check is correctly bypassed since the variable carries the credential itself. README guidance to source it from a secrets manager is a good call. Merging. One note for future PRs: the test file's "seven review categories" scaffolding adds some noise — Closes #8. |
#15 and #16 merge cleanly in git but collide semantically: #15's client_affected_test.go calls the pre-#16 ListMessages signature, so master did not build. Ported those three call sites to ListOptions. Also guards the no-match detection added in #15. CopyCommand.Wait() returns &cmd.data unconditionally in go-imap v2, so the `copyData != nil` half of the check was dead code and the result rested entirely on COPYUID. COPYUID is only sent by servers advertising UIDPLUS (folded into IMAP4rev2); without it an empty SourceUIDs/DestUIDs pair means the server never reported, not that nothing was copied — which would have failed every successful copy/label/move. Extracted copyMatchedNothing(), which draws that conclusion only when the capability guarantees the data. #15's fixture pins Caps to IMAP4rev2 and so could not cover this; added a plain IMAP4rev1 fixture. On such a server COPY no-match detection is necessarily weaker, but MoveMessages still catches it via the STORE affected-count — pinned by TestMoveMissingUIDWithoutUIDPlusStillErrors. Finally, adds #16's new mail list flags (--flagged, --fields, --compact) to the --help-json schema per CLAUDE.md, along with --offset and --page, which were already missing. That output is the documented agent contract. Co-authored-by: exe.dev user <exedev@discovery-lotus.exe.xyz> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Carries forward the unique portion of #13. The env-var and mail-list work in that PR landed independently via #14 and #16, so only the batch command remains; this drops the duplicated implementations rather than conflicting with what shipped. mail batch runs multiple label/unlabel/archive/move/flag/delete operations over a single IMAP session, avoiding a connect and auth round-trip per operation. All operations are validated up front, so malformed input fails before any connection is opened or any mailbox is mutated. Names containing IMAP special characters or CRLF are rejected, and input is capped at 10MB. Also fixes two defects from #13: - The --help-json examples used \" inside raw string literals, which emitted literal backslashes into the agent-facing schema. - docs/commands.md listed `seq` as a --fields name; the implementation that shipped in #16 uses `seq_num`. Adds a CHANGELOG covering everything in 0.2.6 and bumps the version. Closes #10. Co-authored-by: exe.dev user <exedev@discovery-lotus.exe.xyz> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Summary
Headless servers running pm-cli in automated pipelines often have no desktop
session and therefore no D-Bus secret service, so
GetPassword()fails withorg.freedesktop.secrets was not provided by any .service files. This wires anenvironment-variable fallback into
GetPassword()ininternal/config/config.go.GetPassword()now consultsPM_CLI_BRIDGE_PASSWORDbefore the systemkeyring:
non-empty, so interactive users see no change.
the credential directly.
README gains a "Headless / automated environments" section documenting the
variable.
Tests
Added
internal/config/password_env_test.gocovering all seven categories:constant is guarded against drift.
back.
placeholder retained.
go build ./... && go vet ./... && go test ./...all green.Closes #8
🤖 Generated with Claude Code