Skip to content

Allow to define expected values in fields definitions - #616

Merged
jsoriano merged 2 commits into
elastic:mainfrom
jsoriano:fields-expected-values
Sep 27, 2023
Merged

Allow to define expected values in fields definitions#616
jsoriano merged 2 commits into
elastic:mainfrom
jsoriano:fields-expected-values

Conversation

@jsoriano

@jsoriano jsoriano commented Sep 27, 2023

Copy link
Copy Markdown
Contributor

What does this PR do?

Add expected_values to fields definitions.

Why is it important?

This setting would be used in some packages to override values in ECS definitions (see elastic/elastic-package#1472).
It can be used in general to define expected values.

Checklist

Related issues

mrodm
mrodm previously approved these changes Sep 27, 2023
@elasticmachine

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @jsoriano

@jsoriano
jsoriano merged commit 4253eff into elastic:main Sep 27, 2023
@jsoriano
jsoriano deleted the fields-expected-values branch September 27, 2023 17:32
@chrisberkhout

Copy link
Copy Markdown

Thanks for the quick action on this!

I rebuilt elastic-package with this and it did let me define my own expected_values, as in the test. I also tried expected_values: [] (expecting it to allow any values) and that failed with:

file "...fields.yml" is invalid: field 0.expected_values: Invalid type. Expected: array, given: null

I'm not familiar with the steps between the spec and the validation, but I think an array of strings specified in JSON Schema can be empty if it doesn't also have a minItems constraint.

As mentioned elsewhere, I found a different workaround for my immediate issue.

@jsoriano

jsoriano commented Oct 2, 2023

Copy link
Copy Markdown
Contributor Author

Thanks for reporting your finding, I have created an specific issue for that, it may be a general problem with arrays #630

Apart of the validation issue we may need to review how elastic-package combines these settings, as this is currently based on length checks: https://github.com/elastic/elastic-package/blob/9d8ce35eb3051b832057b37e75ad454e28069ee6/internal/fields/dependency_manager.go#L349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests fail due to ECS expected values

4 participants