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

此生再无相见时 提交于 2019-12-24 05:54:08

问题


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?


回答1:


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.




回答2:


Could it be because grouping is not a data definition node and pyang validates only such nodes?

The grouping statement is not a data definition statement and, as such, does not define any nodes in the schema tree.

RFC6020



来源:https://stackoverflow.com/questions/37854667/why-does-pyang-validation-allow-to-define-a-list-without-a-valid-key-if-the-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!