-
Notifications
You must be signed in to change notification settings - Fork 119
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
Fix validation of subfields of flattened objects #2088
Fix validation of subfields of flattened objects #2088
Conversation
💚 Build Succeeded
cc @jsoriano |
if ancestor.Type == "flattened" { | ||
return true | ||
} |
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.
If it finds an ancestor with a different type of "flattened", should this return false directly here?
I was thinking in the case of the ancestor being something like: ancestor.Type = object
and ancestor.ObjectTYpe == "keyword"
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.
Not sure, there are packages defining mappings for subfields of flattened objects (for example here). This doesn't make a lot of sense as a mapping, but this is allowed now, and can be used for example to provide documentation.
We probably should not allow to define mappings under flattened
fields, but this would be a different task, and checked in a different place. And we would need to provide something for cases where developers want to provide docs for flattened subfields.
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.
Not sure, there are packages defining mappings for subfields of flattened objects (for example here). This doesn't make a lot of sense as a mapping, but this is allowed now, and can be used for example to provide documentation.
Ok, I didn't know about this kind of usage.
We probably should not allow to define mappings under flattened fields, but this would be a different task, and checked in a different place. And we would need to provide something for cases where developers want to provide docs for flattened subfields.
Agreed!
i := strings.LastIndex(key, ".") | ||
key = key[:i] | ||
ancestor := FindElementDefinition(key, schema) |
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 this be replaced by findParentElementDefinition ?
i := strings.LastIndex(key, ".") | |
key = key[:i] | |
ancestor := FindElementDefinition(key, schema) | |
ancestor := findParentElementDefinition(key, schema) |
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.
mmm I guess it would be needed to somehow return also the key of the field, or being able to retrieve it from the ancestor
struct.
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.
Yep, this is the problem I found, we still need to loop over the ancestors.
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.
LGTM! Checked locally too with logsdb enabled for audtid_manager
package.
When a document doesn't has subobjects, like when
subobjects: false
or synthetic mode is used, if an undocumented field is found, we need to check its ancestors to see if it is a member of a flattened object.This is producing failures for
auditd_manager
package when LogsDB is enabled: https://buildkite.com/elastic/integrations/builds/15559