Skip to content

Conversation

@zedkipp
Copy link
Contributor

@zedkipp zedkipp commented Nov 26, 2025

This fixes a regression that caused the VS code extension to be unable to authenticate after making keyring usage on by default. This is because the VS code extension assumes the CLI will always use the session token stored on disk, specifically in the directory specified by --global-config.

This fix makes keyring usage enabled when the --global-config directory is not set. This is a bit wonky but necessary to allow the extension to continue working without modification and without backwards compat concerns. In the future we should modify these extensions to either access the credential in the keyring (like Coder Desktop) or some other approach that doesn't rely on the session token being stored on disk.

Tests:
coder login dev.coder.com -> token stored in keyring
coder login --global-config=/tmp/ dev.coder.com -> token stored in /tmp/session

This fixes a regression that caused the VS code extension to be unable
to authenticate after making keyring usage on by default. This is
because the VS code extension assumes the CLI will always use the session
token stored on disk, specifically in the directory specified by
--global-config.

This fix makes keyring usage enabled when the --global-config directory
is not set. This is a bit wonky but necessary to allow the extension to
continue working without modification and without backwards compat concerns.
In the future we should modify these extensions to either access the
credential in the keyring (like Coder Desktop) or some other approach that
doesn't rely on the session token being stored on disk.
@zedkipp zedkipp changed the title fix(cli): don't default to keyring when --global-config set fix(cli): remove defaulting to keyring when --global-config set Nov 26, 2025
@zedkipp zedkipp marked this pull request as ready for review November 26, 2025 07:16
@ibetitsmike
Copy link
Contributor

@codex review

@dannykopping dannykopping added the cherry-pick/v2.29 Needs to be cherry-picked to the 2.29 release branch label Nov 26, 2025
cli/root.go Outdated
// either access the credential in the keyring (like Coder Desktop) or some other
// approach that doesn't rely on the session token being stored on disk. We set the
// global config directory in most CLI tests, so we need to skip this check for tests.
assumeExtensionInUse := r.globalConfig != config.DefaultDir() && !testing.Testing()
Copy link
Contributor

Choose a reason for hiding this comment

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

		!testing.Testing()

this one really rubs me the wrong way (I'd rather have logic in tests that enforce using keyring, but I'll let @deansheather be the final judge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same. I don't see an easy way around this right now. If I unset --global-config in the tests, I think parallel CLI invocations will be reading/writing to the same directory (e.g. URL) and won't have isolation. Any ideas?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I might be able to set the HOME env var in keyring tests to work around this. Checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That didn't work, but I made a way to override this behavior for tests that need to exercise the keyring even though --global-config is set. I also added test coverage for when --global-config is set by modifying how existing CLI tests are setup (removed --use-keyring=false so only --global-config remains).

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@zedkipp zedkipp enabled auto-merge (squash) November 26, 2025 08:52
@zedkipp zedkipp merged commit bbf7b13 into main Nov 26, 2025
32 checks passed
@zedkipp zedkipp deleted the zedkipp/keyring-dir branch November 26, 2025 09:17
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2025
@zedkipp zedkipp removed the cherry-pick/v2.29 Needs to be cherry-picked to the 2.29 release branch label Dec 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants