Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(cli): add error message for bad login URL#4042

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

jsjoeio
Copy link
Contributor

@jsjoeiojsjoeio commentedSep 13, 2022
edited
Loading

This adds a more friendly error message when a user mistypes the user when runningcoder login <url>. Open to additional feedback/suggestions!

Fixes#3963

To test locally, run:

cd cli&& gotest -v -count 1 -run TestLogin/InitialUserBadLoginURL

@jsjoeiojsjoeio linked an issueSep 13, 2022 that may beclosed by this pull request
@jsjoeiojsjoeio self-assigned thisSep 13, 2022
@jsjoeiojsjoeio requested a review froma teamSeptember 13, 2022 18:23
cli/login.go Outdated
@@ -83,7 +83,7 @@ func login() *cobra.Command {

hasInitialUser, err := client.HasFirstUser(cmd.Context())
if err != nil {
return xerrors.Errorf("has initialuser: %w", err)
return xerrors.Errorf("Failed to check server %q for firstuser, is the URL correct and is coder accessible from your browser? Error: %w", serverURL.String(), err)
Copy link
ContributorAuthor

@jsjoeiojsjoeioSep 13, 2022
edited
Loading

Choose a reason for hiding this comment

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

I wish we could print this on two lines:
"friendly message..
error output...
"
but when I add\n it prints the error output twice. Any ideas@deansheather ?

Copy link
Member

Choose a reason for hiding this comment

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

in that case you just write log output to stderr with your message and thenreturn xerrors.Errorf("has initial user: %w", err) afterwards.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I triedfmt.Fprintln(cmd.ErrOrStderr(), errMsg) but then my test doesn't pass. Any pointers?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Talked offline. I'll have it match thehas initial user message.

@jsjoeiojsjoeioforce-pushed the3963-ux-better-error-message-for-coder-login-failure branch froma9bd76c to0782811CompareSeptember 14, 2022 17:40
@@ -83,7 +83,7 @@ func login() *cobra.Command {

hasInitialUser, err := client.HasFirstUser(cmd.Context())
if err != nil {
return xerrors.Errorf("has initial user: %w", err)
return xerrors.Errorf("Failed to check server %q for first user, is the URL correct and is coder accessible from your browser? Error -has initial user: %w", serverURL.String(), err)
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thought about this a bit more last night...Since this is user-facing, I think the friendly error message should be included in the test assertion. Otherwise, it can be removed and the test would still pass. Then we'd have a working CLI with poor UX. Instead, we want to ensure we have good UX.

@jsjoeio
Copy link
ContributorAuthor

cc@deansheather ready for another review

@jsjoeiojsjoeioenabled auto-merge (squash)September 14, 2022 17:49
@jsjoeiojsjoeio merged commit22e49c4 intomainSep 14, 2022
@jsjoeiojsjoeio deleted the 3963-ux-better-error-message-for-coder-login-failure branchSeptember 14, 2022 20:15
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@deansheatherdeansheatherdeansheather approved these changes

Assignees

@jsjoeiojsjoeio

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

ux: better error message for coder login failure
2 participants
@jsjoeio@deansheather

[8]ページ先頭

©2009-2025 Movatter.jp