Search code examples
ietf-netmod-yang

Why does pyang validation allow to define a list without a valid key if the list is in a grouping?


The RFC6020 says:

The "key" statement [...] takes as an argument a string that specifies a space-separated list of leaf identifiers of this list. [...] Each such leaf identifier MUST refer to a child leaf of the list. The leafs can be defined directly in substatements to the list, or in groupings used in the list.

Despite this fact it is possible to successfully validate the below grouping in pyang:

grouping my-grouping {
    list my-list-in-a-grouping {
        key there-is-no-such-leaf;
    }
}

If the list is outside of a grouping, or if I use the grouping without any augmentations, then I get an error (which is expected):

error: the key "there-is-no-such-leaf" does not reference an existing leaf

What is the point of having groupings that require augmentations in order to be used?


Solution

  • According to Martin Bjorklund, an author of the related RFCs, this is not valid YANG. Pyang fails to detect this due to a bug in its implementation. The RFC text which you quoted in your question does not permit any other interpretation and appears to be intentional. Groupings were never meant to be used in such a way.