-
Notifications
You must be signed in to change notification settings - Fork 116
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
Add flattened field validation logic #177
Conversation
For flattened field types don't validate the leaf fields. Fixes elastic#176
internal/fields/validate.go
Outdated
@@ -103,6 +103,9 @@ func (v *Validator) validateMapElement(root string, elem common.MapStr) multierr | |||
} | |||
} | |||
case map[string]interface{}: | |||
if definition := findElementDefinition("", key, v.schema); definition != nil && definition.Type == "flattened" { |
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.
I see that you reused the same invocation as below (findElementDefinition("", key, v.schema)
). I think it's a good moment to refactor it a bit:
findElementDefinition(key, v.schema)
which calls findElementDefinitionForRoot("", key, v.schema)
and apply then same in validateScalarElement()
I would also wrap the entire line with IsFieldFlattened
or similar.
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.
I asked for a small refactoring.
I really appreciate adding the test case. Could you please link the Github issue in the code comment? In general you can add a comment justifying why do we need to treat specially "flattened" fields.
EDIT:
I see that the PR build was aborted. We need a green status to merge the PR once all relevant changes are introduced.
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.
I left one nit-pick. If the PR build goes green, feel free to merge it. You have to bump up the dependency in the Integrations repository (can be done together with your PR).
@mtojek I think you'll need to trigger testing in order to get a green build.
|
jenkins run the tests please |
The tests revealed a few issues. There was an error in the pipeline for update-user-json.log because serviceEventDetails was not present. This was the error "error": { "message": "Cannot invoke \\\"Object.getClass()\\\" because \\\"receiver\\\" is null" } The aws.cloudtrail.read_only field was mapped as keyword but was actual a JSON boolean. I changed the type to boolean, but do not plan to backport this change to Filebeat. And lastly some ECS user_agent fields were missing. This depends on elastic/elastic-package#177 to make the flattened fields pass test validation.
The tests revealed a few issues. There was an error in the pipeline for update-user-json.log because serviceEventDetails was not present. This was the error "error": { "message": "Cannot invoke \\\"Object.getClass()\\\" because \\\"receiver\\\" is null" } The aws.cloudtrail.read_only field was mapped as keyword but was actual a JSON boolean. I changed the type to boolean, but do not plan to backport this change to Filebeat. And lastly some ECS user_agent fields were missing. This depends on elastic/elastic-package#177 to make the flattened fields pass test validation.
The tests revealed a few issues. There was an error in the pipeline for update-user-json.log because serviceEventDetails was not present. This was the error "error": { "message": "Cannot invoke \\\"Object.getClass()\\\" because \\\"receiver\\\" is null" } The aws.cloudtrail.read_only field was mapped as keyword but was actual a JSON boolean. I changed the type to boolean, but do not plan to backport this change to Filebeat. And lastly some ECS user_agent fields were missing. This depends on elastic/elastic-package#177 to make the flattened fields pass test validation.
For flattened field types don't validate the leaf fields.
Fixes #176