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

aucoalesce - Fix yaml.v3 upgrade issues #170

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

andrewkroh
Copy link
Member

@andrewkroh andrewkroh commented Nov 8, 2024

This PR addresses #169 to fix bugs introduced during the upgrade from yaml.v2 to yaml.v3.

  • Add failing test case: A test case has been added to highlight a regression where a test passes under yaml.v2 but fails under yaml.v3.

  • Update yaml.v3 Unmarshaler implementation: The yaml.Unmarshaler interface changed between yaml.v2 and yaml.v3, but the implementation was not updated accordingly. This commit ensures that the yaml.Unmarshaler interface is correctly implemented and adds compile-time checks to ensure proper interface adherence.

  • Flatten keys in normalizations.yaml to avoid deep merge issues: Under yaml.v3, anchors with objects do not perform a deep merge as expected in previous versions. To address this, the structure in normalizations.yaml has been flattened, replacing the object-based merging with a flatter structure. This ensures the expected behavior where keys in later nodes override keys from earlier ones. The flattening of normalizations.yaml was aided by https://gist.github.com/andrewkroh/e7212a1ff033a0227f7c8d3fa7df8973 (white space changes were manually reverted).

  • Enable strict YAML decoding: This change enforces strict decoding of normalizations.yaml to ensure all fields are explicitly defined in the corresponding struct. This helps catch potential typos or undefined fields.

andrewkroh added a commit to andrewkroh/beats that referenced this pull request Nov 8, 2024
@andrewkroh andrewkroh changed the title Bugfix/normalizations yaml v3 aucoalesce - Fix yaml.v3 upgrade issues Nov 8, 2024
andrewkroh added a commit to andrewkroh/beats that referenced this pull request Nov 8, 2024
andrewkroh added a commit to andrewkroh/beats that referenced this pull request Nov 8, 2024
@andrewkroh andrewkroh added the bug label Nov 8, 2024
This test passes under v2.5.0, but fails under v2.6.0.
The yaml.Unmarshaler interface changed between yaml.v2 and
yaml.v3. But our implementations were not updated during
the upgrade process.

This adds compile time checks to ensure that yaml.Unmarshaler is
implemented.
Under yaml.v3 the anchors with objects do not perform a deep merge.

https://yaml.org/type/merge.html

> Keys in mapping nodes earlier in the sequence override keys specified in later mapping nodes.

Given the following, it was previously expected that the second entry
would merge to create {object: {primary: foo, secondary: bar}}, but that
does not happen under v3.

- &my_macro
  object:
    primary: foo

- <<: *my_macro
  object:
    secondary: bar

To address this, instead of using objects this change flattens the structure

The changes to normalizations.yaml were aided by
https://gist.github.com/andrewkroh/e7212a1ff033a0227f7c8d3fa7df8973.
Ensure that all fields in normalizition.yaml are defined
in a struct to avoid typos.
@andrewkroh andrewkroh marked this pull request as ready for review November 8, 2024 21:42
@andrewkroh andrewkroh requested a review from a team November 8, 2024 21:42
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

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

Successfully merging this pull request may close these issues.

2 participants