Skip to content

lyd_diff_apply_all fails on replace operation for non-existing leaf (RFC compliance question) #2372

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

Open
vilkovalexander opened this issue Mar 27, 2025 · 1 comment
Labels
is:question Issue is actually a question.

Comments

@vilkovalexander
Copy link

Hello, and thank you for your work on libyang!

According to RFC 7950, section 7.6.7, the replace operation is intended to behave as a combination of delete and create. In the context of a operation, this implies that if a leaf does not exist and is targeted with replace, it should be created.

However, when using lyd_diff_apply_all() with a diff that includes a replace operation on a non-existent leaf, the function returns an error instead of creating the leaf node.

Example:

leaf foo {
  type string;
}

If the current data tree does not contain foo, and the diff contains a replace operation like foo = "bar", the operation fails rather than creating the foo node with the new value.

Question: Is this the intended behavior in libyang, or is this a deviation from RFC 7950?

Thank you in advance for your clarification!

@michalvasko
Copy link
Member

Be careful, libyang defines functions for diff, which is something else than edit. The latter should fully conform to edit-config operations and is used in sysrepo/netopeer2. diff is a proprietary format representing "resolved edit" meaning every create operation must actually create data, every remove remove them, and every replace replace them.

@michalvasko michalvasko added the is:question Issue is actually a question. label Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:question Issue is actually a question.
Projects
None yet
Development

No branches or pull requests

2 participants