freeconf / yang

Standards-based management for Golang microservices
Apache License 2.0
38 stars 15 forks source link

No error is thrown if cases inside a choice contains child nodes with same name. #79

Closed davidmat50 closed 1 year ago

davidmat50 commented 1 year ago

This is in continuation with https://github.com/freeconf/yang/issues/73

As per https://www.rfc-editor.org/rfc/rfc7950.html#section-7.9.2, The identifiers of all these child nodes MUST be unique within all cases in a choice.

But yang loader does not throw any error in such a case where all child nodes are not unique within the cases.

Exmaple file given below.

module check_similar_identifiers_in_choice {

    namespace "urn:params:check_similar_identifiers";
    prefix check_similar_identifiers;
    yang-version 1.1;

    container root-container {
        choice inner_choice {
            case case-A {
                leaf leaf-root {
                    type enumeration {
                        enum "three";
                        enum "four";
                    }
                }
            }
            case case-B {
                leaf leaf-root {
                    type enumeration {
                        enum "five";
                        enum "six";
                    }
                }
            }
        }
    }
}

In the above exmaple 'leaf leaf-root' is duplicate name among the cases. The leaf is ignored in the resulted data tree after loading, But no error was thrown by LoadModule() to indicate this incorrect configuration.

dhubler commented 1 year ago

little behind, but i'll take a look in next few days

dhubler commented 1 year ago

fixed