-
Notifications
You must be signed in to change notification settings - Fork 126
[system tests] Revisit multierrors when validating documents #2455
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
Conversation
if len(errs) == 0 { | ||
return nil | ||
} | ||
return errs | ||
return errs.Unique() |
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.
This error variable comes from validateMapElement
that returns a multierror.Error.
That's why here I updated all the functions calling this to return also multierror.Error (parseSingleElementValue
and others)
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.
Remove parsing field value failed:
from the error messages
💚 Build Succeeded
History
cc @mrodm |
errs := v.parseElementValue(key, *definition, val, doc) | ||
if len(errs) > 0 { | ||
return errs.Unique() |
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.
One of the main changes in this PR, here it is removed the parsing field value failed
from the error (and just return all the errors that could be found).
To avoid errors in the output like:
[0] parsing field value failed: [0] field "gcp.firewall.rule_details.ip_port_info.ip_protocol" is undefined
[1] field "gcp.firewall.rule_details.ip_port_info.port_range" is undefined
[1] parsing field value failed: [0] field "gcp.firewall.rule_details.ip_port_info.port_range" is undefined
[1] field "gcp.firewall.rule_details.ip_port_info.ip_protocol" is undefined
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.
Could those errors be reported without adding parsing field value failed
?
Another example found:
[0] parsing field value failed: [0] parsing field value failed: field "cloudflare_logpush.email_security_alerts.attachments.Decrypted"'s Go type, bool, does not match the expected field type: keyword (field value: true)
[1] parsing field value failed: field "cloudflare_logpush.email_security_alerts.attachments.Encrypted"'s Go type, bool, does not match the expected field type: keyword (field value: true)
With the changes introduced in this PR, those errors would be written as:
[0] field "cloudflare_logpush.email_security_alerts.attachments.Decrypted"'s Go type, bool, does not match the expected field type: keyword (field value: true)
[1] field "cloudflare_logpush.email_security_alerts.attachments.Encrypted"'s Go type, bool, does not match the expected field type: keyword (field value: true)
test integrations |
Created or updated PR in integrations repository to test this version. Check elastic/integrations#12974 |
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.
Nice, thanks!
@@ -672,14 +670,17 @@ func (v *Validator) validateMapElement(root string, elem common.MapStr, doc comm | |||
|
|||
err := v.validateScalarElement(key, val, doc) | |||
if err != nil { | |||
errs = append(errs, err) | |||
errs = append(errs, err...) |
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.
👍
There are some scenarios that running system tests in packages could lead to duplicated errors like this one:
This can be observed when the
gcp
package is tested updating its format_version to be3.0.1
.The errors shown to the user should be like:
This PR revisits the usage of
multierrors
when validating the documents in system tests to show just unique errors.How to test this PR locally