gnmic icon indicating copy to clipboard operation
gnmic copied to clipboard

Returning malformed xpath key when key with null value is passed in the path.

Open LightBringer3six opened this issue 10 months ago • 2 comments

Request : -p /A/B[x=1][y='']/C

error is given- building get request failed: invalid value: malformed xpath key
Error: one or more path failed

I am requesting a list B for which one of the keys, say y='', has null value. When I pass this key in the path, it returns the error.

LightBringer3six avatar Feb 17 '25 05:02 LightBringer3six

Typically keys must have values if your gNMI server is backed by a YANG schema:

https://datatracker.ietf.org/doc/html/rfc7950#section-7.8.2

The combined values of all the leafs specified in the key are used to
   uniquely identify a list entry.  All key leafs MUST be given values
   when a list entry is created.  Thus, any default values in the key
   leafs or their types are ignored.  Any "mandatory" statements in the
   key leafs are ignored.

But your issue is really shell quoting and escape rules, it gets rid of '' and passes it as en empty string. If should work as expected if you change the path to /A/B[x=1][y=\'\']/C

karimra avatar Feb 17 '25 15:02 karimra

Thanks for the RFC @karimra . About that last bit you added regarding escape rules!. When I requested the above-mentioned path with [y=''] it said "Unexpected data after path". I guess without \ is working for me. It's just I need to have values for all the keys. Please add if anything I need to know.

LightBringer3six avatar Feb 18 '25 05:02 LightBringer3six