Skip to content

fix(cli): fix coder login token failing without --url flag#22742

Merged
kacpersaw merged 1 commit into
mainfrom
zedkipp/login-token-url
Mar 10, 2026
Merged

fix(cli): fix coder login token failing without --url flag#22742
kacpersaw merged 1 commit into
mainfrom
zedkipp/login-token-url

Conversation

@zedkipp
Copy link
Copy Markdown
Contributor

@zedkipp zedkipp commented Mar 7, 2026

Previously coder login token didn't load the server URL from config, so it always required --url or CODER_URL when using the keyring to store the session token. This command would only print out the token when already logged in to a deployment and file storage is used to store the session token (keyring is the default on Windows/macOS). It would also print out an incorrect token when --url was specified and the session token stored on disk was for a different deployment that the user logged into.

This change fixes all of these issues, and also errors out when using session token file storage with a --url argument that doesn't match the stored config URL, since the file only stores one token and would silently return the wrong one.

See #22733 for a table of the before/after behaviors.

@zedkipp zedkipp force-pushed the zedkipp/login-token-url branch from f4f3c30 to fbbb46d Compare March 9, 2026 15:23
@zedkipp zedkipp requested a review from kacpersaw March 9, 2026 15:45
@zedkipp zedkipp marked this pull request as ready for review March 9, 2026 15:45
@zedkipp zedkipp force-pushed the zedkipp/login-token-url branch 2 times, most recently from 1d1b3dd to 13eef14 Compare March 9, 2026 15:52
`coder login token` didn't load the server URL from config, so it
always required --url or CODER_URL when using the keyring. This command
would only print out the token when already logged in to a deployment
and file storage is used to store the session token (keyring is the
default on Windows/macOS). It would also print out an incorrect token
when --url was specified and the session token stored on disk was for
a different deployment that the user logged into.

Also error when using the file backend with a --url that doesn't
match the stored config URL, since the file backend only stores one
token and would silently return the wrong one.
@zedkipp zedkipp force-pushed the zedkipp/login-token-url branch from 13eef14 to bfb24f3 Compare March 9, 2026 16:34
@kacpersaw kacpersaw merged commit 14341ed into main Mar 10, 2026
43 of 45 checks passed
@kacpersaw kacpersaw deleted the zedkipp/login-token-url branch March 10, 2026 07:57
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 10, 2026
@matifali
Copy link
Copy Markdown
Member

matifali commented Mar 10, 2026

@EhabY does this affect VS code extension? Do you think we should back port this to 2.31 release?

@EhabY
Copy link
Copy Markdown
Contributor

EhabY commented Mar 10, 2026

We always pass the URL, so this should not affect the VS Code extension (once released on stable)

For reference, we call coder --header-command <HEADER COMMAND> login --use-token-as-session <URL>

also errors out when using session token file storage with a --url argument that doesn't match the stored config URL, since the file only stores one token and would silently return the wrong one.

@zedkipp Is this only for the global --url option and not the URL argument for login?

@zedkipp
Copy link
Copy Markdown
Contributor Author

zedkipp commented Mar 10, 2026

@matifali @EhabY this should have no impact to the extension since it only closes up a few holes and unifies behavior when the keyring or a file is used to store the session token. The --url option is indeed the global option, and the only behavior when that option is specified that has changed is when the token is stored in a file on disk and the --url option doesn't match what deployment the user is logged into. I put a table in #22733 with the before/after behaviors.

@EhabY
Copy link
Copy Markdown
Contributor

EhabY commented Mar 10, 2026

the only behavior when that option is specified that has changed is when the token is stored in a file on disk and the --url option doesn't match what deployment the user is logged into.

Ah thanks, all good from the VS Code side then!

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