netmod-wg / yang-next

Feature requests for future versions of YANG
6 stars 0 forks source link

Relax rules for identityref representation without a prefix #127

Open abierman opened 5 months ago

abierman commented 5 months ago

Problem

There are several YANG modules that have must/when XPath that compares an identityref leaf to a string literal.

          uses terminal-otn-protocol-top {
              when "config/logical-channel-type = 'PROT_OTN'" {
              description
                "Include the OTN protocol data only when the
                 channel is using OTN framing.";
            }
        }

The strict rules in the RFC (sec 9.10) say that the identity (e.g. PROT_OTN) MUST be defined in the current module.

This is often not done.

Solution

schoenw commented 1 month ago

What happens if the string matches multiple definitions?

If we allow leaving out prefixes in situations where there is no ambiguity, should we not do this systematically and not just in when/must expressions? Having to remember where I am allowed to leave out prefixes and where not may make it harder to write proper YANG. (I do not know whether any good language servers exist for YANG but tools like that can also take care of getting the details straight.)

schoenw commented 1 month ago

I guess we did insist on unambiguous identifiers to prevent situations where an update of an imported module suddenly causes name clashes in importing modules. So it is a question of convenience vs. robustness; if you don't like surprises, better use fully qualified names.

abierman commented 1 week ago

Agree to close this issue. Leaving out the prefix is a common issue. In general we should make YANG easier to use. This would change the meaning of a missing prefix.

Close: complexity: medium, bc: low, importance: low