Skip to content

parse: don't point to the wrong node on validation #343

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

Merged
merged 2 commits into from
Apr 26, 2023

Conversation

daniloegea
Copy link
Contributor

@daniloegea daniloegea commented Apr 20, 2023

The function validate_netdef_grammar() checks several properties from the netdef that are not related to the current context (YAML node). This leads to error messages like these ones:

foo.yaml:5:7: Error ...: eth0: 'set-name:' requires 'match:' properties
      macaddress: c0:f3:7e:35:8e:1b
      ^
foo.yaml:5:7: Error in ...: wlan0: No access points defined
      macaddress: c0:f3:7e:35:8e:1b
      ^

Using the YAML tree node here doesn't seem to make sense, but removing it would break the ABI.

Description

Checklist

  • Runs make check successfully.
  • Retains 100% code coverage (make check-coverage).
  • New/changed keys in YAML format are documented.
  • (Optional) Adds example YAML for new feature.
  • (Optional) Closes an open bug in Launchpad.

The function validate_netdef_grammar() checks several properties from
the netdef that are not related to the current context (YAML node). This
leads to error messages like these ones:

foo.yaml:5:7: Error ...: eth0: 'set-name:' requires 'match:' properties
      macaddress: c0:f3:7e:35:8e:1b
      ^

foo.yaml:5:7: Error in ...: wlan0: No access points defined
      macaddress: c0:f3:7e:35:8e:1b
      ^

Using the YAML tree node here doesn't seem to make sense, but removing
it would break the ABI.
@daniloegea daniloegea marked this pull request as draft April 20, 2023 13:17
@daniloegea daniloegea requested a review from slyon April 20, 2023 13:17
@slyon
Copy link
Collaborator

slyon commented Apr 24, 2023

The change looks sensible to me. Could you please give some more context on how this would break ABI? Our ABI checker CI seems to be happy..

@daniloegea
Copy link
Contributor Author

I mean, if we don't want to use the YAML node we could remove it from the functions parameters (the third one).

Copy link
Collaborator

@slyon slyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you mean it would chance ABI when we drop the yaml_node_t* node argument from the function signature?

I assume the easiest would be to just pass NULL from "parse.c", as is done in "parse-nm.c". But I agree the YAML context/node isn't really needed inside this validation function. So cleaning up the singature is fine with me too. The function is not exported publicly, and all consumers are part of libnetplan, so I don't think it should break anything if we drop that parameter from the signature. If needed we could mute that specific case in abi-compat/suppressions.abignore.

It doesn't make much sense having it since the validation will emit
errors not related to the node.
@daniloegea daniloegea marked this pull request as ready for review April 26, 2023 12:03
Copy link
Collaborator

@slyon slyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

And the ABI checker seems to be happy, too :)

@slyon slyon merged commit c2bb6ca into canonical:main Apr 26, 2023
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.

2 participants