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

chore: add validation errors to the cli output#12814

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
Emyrk merged 4 commits intomainfromstevenmasley/cli_validation_errors
Apr 2, 2024

Conversation

Emyrk
Copy link
Member

@EmyrkEmyrk commentedMar 28, 2024
edited
Loading

Closes#12575

Error:

{Response: codersdk.Response{Message:"Top level sdk error message.",Detail:"magic dust unavailable, please try again later",Validations: []codersdk.ValidationError{{Field:"region",Detail:"magic dust is not available in your region",},},}Helper:"Have you tried turning it off and on again?"}

Before:

Screenshot from 2024-03-28 14-55-53

After:

Screenshot from 2024-03-28 14-55-09

If you did not know,coder exp example-error <subcommand> has a set of sub commands to see how different cli errors are rendered out. No need to make them occur naturally.

Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

Looks great!

I think the validation errors could be in yellow though, to make them stand out more?
Also can you please add a couple unit tests?

@Emyrk
Copy link
MemberAuthor

Emyrk commentedMar 29, 2024
edited
Loading

Also can you please add a couple unit tests?

Unfortunately the cli golden file code (which is the only unit test that makes sense for formatting output) does not handle errors. This is because all cli tests invoke the command from within Go, skipping theerror handler.

You can see this is how we run it in a test:

err:=inv.Run()

Refactoring this will likely break a lot of cli tests since the goerror is more useful then it's text.

I do not want to add a new golden file test for this formatter in this PR. We can come back to testing if we really have formatting drift issues.

Edit: Just found an old issue I made:#11588. Exactly this.

@Emyrk
Copy link
MemberAuthor

Screenshot from 2024-03-29 09-03-05

I made it yellow though!

@dannykopping
Copy link
Contributor

Edit: Just found an old issue I made:#11588. Exactly this.

@Emyrk given this is now in place, should we add a couple tests to it to encompass the new functionality?
I'm not so much worried about formatting errors as regressions; if we change the way we attach validation errors to thecodersdk.Error or some other transitive change, this will represent a degradation in UX on the CLI.

I made it yellow though!

Looks great! Thanks

@Emyrk
Copy link
MemberAuthor

@Emyrk given this is now in place, should we add a couple tests to it to encompass the new functionality? I'm not so much worried about formatting errors as regressions; if we change the way we attach validation errors to thecodersdk.Error or some other transitive change, this will represent a degradation in UX on the CLI.

Tests were added here. These cover all example errors, which covers the validation errors here. I'll rebase on main to get them.

#12698

@EmyrkEmyrkforce-pushed thestevenmasley/cli_validation_errors branch fromcb1b2ba to13bd167CompareApril 2, 2024 14:36
Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Emyrk reacted with thumbs up emoji
@EmyrkEmyrk merged commit5137433 intomainApr 2, 2024
@EmyrkEmyrk deleted the stevenmasley/cli_validation_errors branchApril 2, 2024 15:02
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsApr 2, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@dannykoppingdannykoppingdannykopping approved these changes

Assignees

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

bug(cli): API validation errors are not displayed
2 participants
@Emyrk@dannykopping

[8]ページ先頭

©2009-2025 Movatter.jp