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: improve dynamic parameter validation errors#18501

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 2 commits intomainfromstevenmasley/dynamic_valid_errors
Jun 23, 2025

Conversation

Emyrk
Copy link
Member

@EmyrkEmyrk commentedJun 23, 2025
edited
Loading

What this does

The currentBuildError response fromwsbuilder does not support rich errors from validation. Changed this to use theValidations block of codersdk responses to return all errors for invalid parameters.


Example http response

{"message":"Unable to validate parameters","validations": [        {"field":"big_number","detail":"Invalid parameter value according to 'validation' block; Number must be between 500 and 1000"        },        {"field":"colors","detail":"Values must be a valid option; Value\"[\\\"potatoe\\\"]\" is not a valid option, values\"potatoe\" are missing from the options"        },        {"field":"intro","detail":"Invalid parameter value according to 'validation' block; All messages must start with 'Hello' (value\"Goodbye!\" does not match\"^Hello\")"        }    ]}

Cli error

Screenshot From 2025-06-23 10-17-26

@EmyrkEmyrkforce-pushed thestevenmasley/dynamic_validate branch from0e3dc00 toa51570aCompareJune 23, 2025 14:31
@EmyrkEmyrkforce-pushed thestevenmasley/dynamic_valid_errors branch 3 times, most recently from0923f4d to817afe8CompareJune 23, 2025 15:20
@EmyrkEmyrk marked this pull request as ready for reviewJune 23, 2025 15:21
@EmyrkEmyrk changed the base branch fromstevenmasley/dynamic_validate tographite-base/18501June 23, 2025 16:11
@EmyrkEmyrkforce-pushed thegraphite-base/18501 branch from4f52076 toc1d05a0CompareJune 23, 2025 16:45
@EmyrkEmyrkforce-pushed thestevenmasley/dynamic_valid_errors branch from817afe8 to21556dbCompareJune 23, 2025 16:45
@EmyrkEmyrk changed the base branch fromgraphite-base/18501 tostevenmasley/dynamic_validateJune 23, 2025 16:45
@EmyrkEmyrkforce-pushed thestevenmasley/dynamic_validate branch fromc1d05a0 to129235bCompareJune 23, 2025 16:59
@EmyrkEmyrkforce-pushed thestevenmasley/dynamic_valid_errors branch from21556db to5f30d20CompareJune 23, 2025 17:00
@EmyrkEmyrkforce-pushed thestevenmasley/dynamic_validate branch from129235b to6a5ee9eCompareJune 23, 2025 17:04
@EmyrkEmyrkforce-pushed thestevenmasley/dynamic_valid_errors branch from5f30d20 to40063cdCompareJune 23, 2025 17:04
@EmyrkEmyrkforce-pushed thestevenmasley/dynamic_validate branch 2 times, most recently from0523a2f tof4e5548CompareJune 23, 2025 17:18
@EmyrkEmyrkforce-pushed thestevenmasley/dynamic_valid_errors branch 2 times, most recently from686b2f7 to6849a80CompareJune 23, 2025 17:18
@EmyrkEmyrkforce-pushed thestevenmasley/dynamic_validate branch fromf4e5548 to0523a2fCompareJune 23, 2025 17:18
@EmyrkEmyrk changed the base branch fromstevenmasley/dynamic_validate tographite-base/18501June 23, 2025 17:35
@EmyrkEmyrkforce-pushed thegraphite-base/18501 branch from0523a2f to82af2e0CompareJune 23, 2025 17:35
@EmyrkEmyrkforce-pushed thestevenmasley/dynamic_valid_errors branch from6849a80 toa5f35ddCompareJune 23, 2025 17:35
@graphite-appgraphite-appbot changed the base branch fromgraphite-base/18501 tomainJune 23, 2025 17:36
@EmyrkEmyrkforce-pushed thestevenmasley/dynamic_valid_errors branch froma5f35dd to3c2904cCompareJune 23, 2025 17:36
@EmyrkEmyrk requested a review fromjohnstcnJune 23, 2025 17:36
Comment on lines +30 to +31
Diagnostics hcl.Diagnostics
Parametermap[string]hcl.Diagnostics
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: unexport and return a clone via method?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

No one should really mutate the diagnostics. But I can do that 👍

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Actually I am going to leave it for now. If I make a method to export it, I would either need 1 method to return both diag sets. Or 2 methods. I think the usage is less intuitive in those cases.

func (e*ResolveError)Diagnostics()(hcl.Diagnostics,map[string]hcl.Diagnostics)// Or// This name is not ideal, since Diagnostics does not include the parameter ones :thinking:func (e*ResolveError)Diagnostics()(hcl.Diagnostics)func (e*ResolveError)ParameterDiagnostics()(map[string]hcl.Diagnostics)

johnstcn reacted with thumbs up emoji
Validations:nil,
}

forname,diag:=rangeparameterErr.Parameter {
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: sort map keys for deterministic output?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Good idea 👍

@EmyrkEmyrk merged commit5ed0c7a intomainJun 23, 2025
35 checks passed
@EmyrkEmyrk deleted the stevenmasley/dynamic_valid_errors branchJune 23, 2025 20:08
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJun 23, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

Assignees

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Emyrk@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp