-
Notifications
You must be signed in to change notification settings - Fork 672
Resolve validation error #3634
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
Resolve validation error #3634
Conversation
e095c93
to
7c55bd8
Compare
7fac679
to
7b24bcd
Compare
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.
Pull Request Overview
This PR updates the validation logic to accumulate all errors found in a Lima YAML template and return them together, rather than bailing out at the first error. Tests are adjusted to verify substrings in the combined error message.
- Replace single-error returns with
errors.Join
accumulation inValidate
,validateFileObject
, and part ofvalidateNetwork
- Wrap the aggregated errors at the end of
Validate
with a"validation failed: %w"
prefix - Update unit tests to use
assert.ErrorContains
when expecting error messages
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
pkg/limayaml/validate.go | Switched early return calls to error accumulation; added final wrapping of all errors |
pkg/limayaml/validate_test.go | Changed assertions from assert.Error to assert.ErrorContains |
Comments suppressed due to low confidence (1)
pkg/limayaml/validate_test.go:19
- Add a new test where multiple invalid fields are set simultaneously, and assert that
Validate
returns all errors to ensure aggregation behaves as expected.
func TestValidateProbes(t *testing.T) {
7b24bcd
to
b9dd5cf
Compare
b9dd5cf
to
6cc671d
Compare
pkg/limayaml/validate_test.go
Outdated
@@ -86,7 +87,7 @@ additionalDisks: | |||
assert.NilError(t, err) | |||
|
|||
err = Validate(y, false) | |||
assert.Error(t, err, "field `additionalDisks[0].name is invalid`: identifier must not be empty") | |||
assert.ErrorContains(t, err, "field `additionalDisks[0].name is invalid`: identifier must not be empty") |
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.
please revert:
assert.ErrorContains(t, err, "field `additionalDisks[0].name is invalid`: identifier must not be empty") | |
assert.Error(t, err, "field `additionalDisks[0].name is invalid`: identifier must not be empty") |
6cc671d
to
67d1d7e
Compare
Signed-off-by: Horiodino <holiodin@gmail.com> updatec test-cases Signed-off-by: Horiodino <holiodin@gmail.com> using err.join Signed-off-by: Horiodino <holiodin@gmail.com>
67d1d7e
to
69f223f
Compare
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.
Thanks, LGTM
This PR enhances the limayaml.Validate() function to collect and return all validation errors found in a Lima template, instead of stopping at the first encountered error.
Fixes: #3606
Updated the validation logic to accumulate multiple validation errors.