Skip to content

fix(secrets): allow empty GOG_KEYRING_PASSWORD to skip prompt#153

Closed
tonimelisma wants to merge 1 commit intoopenclaw:mainfrom
tonimelisma:fix/empty-keyring-password
Closed

fix(secrets): allow empty GOG_KEYRING_PASSWORD to skip prompt#153
tonimelisma wants to merge 1 commit intoopenclaw:mainfrom
tonimelisma:fix/empty-keyring-password

Conversation

@tonimelisma
Copy link
Copy Markdown
Contributor

Summary

  • Use os.LookupEnv instead of os.Getenv to detect when GOG_KEYRING_PASSWORD is explicitly set to an empty string
  • This allows users to skip the interactive passphrase prompt by setting GOG_KEYRING_PASSWORD=""

Problem

Previously, setting GOG_KEYRING_PASSWORD="" would still trigger the interactive password prompt because os.Getenv returns an empty string for both "not set" and "set to empty".

Solution

Use os.LookupEnv which returns (value, isSet), allowing us to distinguish between:

  • Env var not set → use terminal prompt (existing behavior)
  • Env var set to any value (including empty) → use that value as password

Test plan

  • Set GOG_KEYRING_PASSWORD="" and verify no prompt appears
  • Unset GOG_KEYRING_PASSWORD and verify prompt still appears
  • Set GOG_KEYRING_PASSWORD="somepass" and verify no prompt appears

🤖 Generated with Claude Code

Previously, setting GOG_KEYRING_PASSWORD="" would still trigger the
interactive password prompt because os.Getenv returns empty string
for both "not set" and "set to empty".

Use os.LookupEnv to distinguish between these cases, allowing users
to explicitly set an empty password to skip the prompt.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@tonimelisma
Copy link
Copy Markdown
Contributor Author

I'm trying to use gog with openclaw. The agent runs without a TTY, and I don't have gnome-keyring or kwallet installed on my system.

Currently this fails because:

  1. No system keyring available → falls back to file backend
  2. File backend requires a passphrase
  3. No TTY available → cannot prompt for passphrase
  4. Setting GOG_KEYRING_PASSWORD="" doesn't work because the code treats empty string as "not set"

Error from OpenClaw:
{
"status": "error",
"tool": "exec",
"error": "read token for account@gmail.com: read token: no TTY available for keyring file backend password prompt; set GOG_KEYRING_PASSWORD\n\nCommand
exited with code 1"
}

This fix allows setting GOG_KEYRING_PASSWORD="" to explicitly use an empty passphrase, enabling non-interactive use of the file backend without requiring a system keyring.

itsjeremyjohnson added a commit to Robben-Media/gogcli that referenced this pull request Feb 16, 2026
- fix: Go version in go.mod (PR openclaw#158)
- fix(secrets): allow empty GOG_KEYRING_PASSWORD to skip prompt (PR openclaw#153)
- fix(auth): add gmail readonly scope and fix drive readonly accumulation (PR openclaw#113)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@steipete
Copy link
Copy Markdown
Collaborator

steipete commented Mar 8, 2026

Thanks. This is already on main now, so I am closing this as superseded.

Current main already uses os.LookupEnv / explicit passwordSet handling for GOG_KEYRING_PASSWORD, so empty-string is treated as intentional rather than falling through to a TTY prompt. It also has regression coverage in internal/secrets/store_more_test.go for the empty-password case.

Keeping the newer landed fix avoids duplicate history.

@steipete steipete closed this Mar 8, 2026
@tonimelisma tonimelisma deleted the fix/empty-keyring-password branch March 8, 2026 03:14
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.

2 participants