bug with positional predicate
I'm finding that if I do a:
err = lyd_new_path2(NULL, ly_native_ctx, xpath, NULL, 0, 0,
LYD_NEW_PATH_UPDATE, NULL, trunk);
where xpath is a path that ends in a keyless list entry with a positional predicate (e.g., /foos/foo[2]) I get a new node back. This must be a bug b/c i'm starting from an empty tree and asking for the second node in a keyless list. It's returning a single list node with no siblings IOW /foos/foo[1].
FWIW same issue exists when foo is a leaf-list.
What exactly would you expect to happen in your use-case? The only unexpected (undocumented) behavior is that any invalid indices are always normalized to the closest valid index, in this case 2 -> 1. In other words, any index higher than the current number of instances causes a new instance to be created.
I would expect the same thing as if I tried to query a missing element and it couldn't return it -- I would expect it to error. Returning "something close" seems really sub-optimal, it would be like me trying to create a string node and libyang truncating the string b/c it couldn't handle the larger value I gave it, and then returning that with a success indication.
The very first time someone complains about this but I have no issue with whichever functioning so an error should now be printed.