Skip to content
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

Field validation failing for array of objects #1488

Closed
andrewkroh opened this issue Oct 5, 2023 · 1 comment · Fixed by #1489
Closed

Field validation failing for array of objects #1488

andrewkroh opened this issue Oct 5, 2023 · 1 comment · Fixed by #1489
Labels
question Further information is requested

Comments

@andrewkroh
Copy link
Member

andrewkroh commented Oct 5, 2023

I'm trying to address validation errors for a field that was declared as type: array. This array contains a list of objects. The fields within these objects are fully specified in the mapping. I thought I should be able to remove the field entry where type: array is used (like this). Given how Elasticsearch flattens arrays of objects, the intermediate objects should have been implicit (e.g. for a field foo.bar we don't require a foo entry). But when I do this the pipeline tests begin failing with field "powershell.command.invocation_details" is undefined.

Another potential fix would be to explicitly declare the invocation_details as type: object, but this solution would run afoul with elastic/package-spec#628. I could also make this nested, but I don't need that capability.

I think our goal with the validation is to ensure that we have mappings for all of the leaf fields. To meet that goal I think elastic-package needs to flatten arrays of objects like Elasticsearch does before applying the field validation.

What would you recommend to make this pipeline test field validation pass?


This is a simplified example of the issue.

---
- name: foo.bar
  type: keyword
{
  "foo": [
    {
      "bar": "baz"
    },
    {
      "bar": "baz"
    }
  ]
}
@andrewkroh andrewkroh added the question Further information is requested label Oct 5, 2023
@jsoriano
Copy link
Member

jsoriano commented Oct 5, 2023

What would you recommend to make this pipeline test field validation pass?

I think that the only option for this case would be to define invocation_details as a group and define the individual fields inside.

Using arrays of objects this way is actually tested, but not recommended, and its validation is not implemented.

I will try to slip in validation for these cases for Package Spec v3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants