Clarify pre-existing token env var error during login#2658
Clarify pre-existing token env var error during login#2658drewrisinger wants to merge 1 commit intocli:trunkfrom drewrisinger:dr-pr-issue-2304-ghtoken-message
Conversation
|
I would add quotes around the variable, aside of that I approve this pr |
|
An of course, thanks a ton @drewrisinger 🥇 |
Occurs when a pre-existing GITHUB_TOKEN or github enterprise token exists in the environment variables while running ``gh auth login``.
|
@drewrisinger it seems that I don't have permissions to approve your PR |
mislav
left a comment
There was a problem hiding this comment.
That's right, our team is not around much until the 2nd week of January. 🙇
| if hostname != "" && key == "oauth_token" { | ||
| if token, env := AuthTokenFromEnv(hostname); token != "" { | ||
| return fmt.Errorf("read-only token in %s cannot be modified", env) | ||
| return fmt.Errorf("The '%s' environment variable is not empty, please clear it to save authentication data", env) |
There was a problem hiding this comment.
It's an improvement, but I'm not 100% sure either about this new error message. It makes it sound like setting GITHUB_TOKEN or GH_TOKEN in your environment is something wrong that you should clear to proceed.
Since setting environment variables is a perfectly valid way to authenticate, maybe the error message shouldn't instruct users to clear the environment variable, but should instruct them to change the token that's saved in the variable if they need to re-authenticate?
There was a problem hiding this comment.
Options:
This command is not compatible with pre-existing environment variable '%s'. You will need to confirm & update the variable yourself as needed.Pre-existing login token '%s' recognized. If you want this application to manage your login, clear the environment variable.Pre-existing login token '%s' recognized. Re-authentication will require changing the environment variable manually.
There was a problem hiding this comment.
Thank you for the suggestions. Upon further deliberation, I decided that the config package isn't the right place to print an error message about environment variables being read-only. Instead, that responsibility should fall on auth commands themselves. I've opened an alternate PR here #2813
Summary
Clarifies the error and steps to remedy it when the GITHUB_TOKEN (or enterprise token) environment variable is set before
gh auth login.closes #2304
Details
Based on suggested text by @georgettica in #2304