-
Notifications
You must be signed in to change notification settings - Fork 31
Improve the error messages for when the user provides a bad password #2530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Captures the underlying package's text-based error and converts it to a first-class named error, allowing us to test with `errors.Is(...)`.
h2zh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve with optional suggestion.
I think the "how to reset password" prompt should also be added to printConfig func, when password error is detected.
| if errors.Is(attemptErr, config.ErrIncorrectPassword) { | ||
| fmt.Fprintln(os.Stderr, "Failed to access local credential file - entered incorrect local decryption password") | ||
| fmt.Fprintln(os.Stderr, "If you have forgotten your password, you can reset the local state (deleting all on-disk credentials)") | ||
| fmt.Fprintf(os.Stderr, "by running '%s credentials reset-local'\n", os.Args[0]) | ||
| os.Exit(1) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use a helper function? For example:
func printPasswordError(err error, actionText string) {
if errors.Is(err, config.ErrIncorrectPassword) {
fmt.Fprintf(os.Stderr, "Failed to %s - entered incorrect local decryption password\n", actionText)
fmt.Fprintln(os.Stderr, "If you have forgotten your password, you can reset the local state (deleting all on-disk credentials)")
fmt.Fprintf(os.Stderr, "by running '%s credentials reset-local'\n", os.Args[0])
os.Exit(1)
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second creating a helper function, so changes to the text are consistent.
I also suggest adjusting the text like so:
- fmt.Fprintf(os.Stderr, "Failed to %s - entered incorrect local decryption password\n", actionText)
+ fmt.Fprintf(os.Stderr, "Failed to %s - password is incorrect\n", actionText)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If password is incorrect is too vague, then maybe password for local credentials is incorrect.
|
Pinging @aowen-uwmad on this since I think this has a lot of overlap with #2793 -- can we knock out both with one PR? |
|
@jhiemstrawisc , here's what I propose (#2793 (comment)): The message prompt for creating a new password should be and the message prompt for entering the password should be |
Captures the underlying package's text-based error and converts it to a first-class named error, allowing us to test with
errors.Is(...).