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

Empty arrays are turned into nil #188

Closed
pebrc opened this issue Oct 15, 2021 · 0 comments · Fixed by #189
Closed

Empty arrays are turned into nil #188

pebrc opened this issue Oct 15, 2021 · 0 comments · Fixed by #189

Comments

@pebrc
Copy link
Contributor

pebrc commented Oct 15, 2021

When parsing empty arrays from YAML to config objects and unpacking into an untyped representation like map[string]interface{} arrays in the original source are turned into nil. Marshalling back to YAML this turns into null and is thereby not round-trippeable through ucfg:

Consider:

node.roles: []
input, err := yaml.Unmarshal(`node.roles: []`)
...
c, err := NewConfig([]byte(input))
...
var output map[string]interface{}
err = c.Unpack(output)
...
yaml.Marshal(output)

leaves us with:

node.roles: null

We have been hit in the ECK operator a couple of times by this issue:

We are using untyped map[string]interface{} target data structures in the operator for application configuration because it is difficult for us to model each Elastic stack application's configuration completely and for all versions of the Elastic stack that we need to support.

@kvch kvch closed this as completed in #189 Nov 10, 2021
kvch pushed a commit that referenced this issue Nov 10, 2021
This adds a special case for empty arrays when reifying configuration objects during Unpack. This is a breaking change compared to existing behaviour as visible in the test cases I adjusted. The original issue #160 that introduced said tests is however still addressed.

Closes #188
andrewkroh added a commit to elastic/beats that referenced this issue Jul 20, 2022
The module tests were failing because the empty tags array was being discarded
resulting in the tags value being treated as `nil`. And this was not being accepted as
a valid type for the inList function.

The cause was elastic/go-ucfg#188.
andrewkroh added a commit to elastic/beats that referenced this issue Jul 26, 2022
…ation (#32422)

* system.auth - sync pipeline with Fleet integration (#32360)

Sync the pipeline for the system.auth dataset with the Fleet integration
from elastic/integrations#3705.

This removes the event.type authentication_failed and authentication_success
values which are not allowed as per ECS. You can use event.category: authentication
and event.outcome: success/failure to query instead.

(cherry picked from commit 475dd7e)

* Update go-ucfg to v0.8.6

The module tests were failing because the empty tags array was being discarded
resulting in the tags value being treated as `nil`. And this was not being accepted as
a valid type for the inList function.

The cause was elastic/go-ucfg#188.

* Fix tests affected by go-ucfg upgrade

Backport fix from 0022ea4.

Co-authored-by: Andrew Kroh <[email protected]>
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 a pull request may close this issue.

1 participant