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 7 months ago

abierman commented 7 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 3 months 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 3 months 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 2 months 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

kwatsen commented 1 month ago

Sounds like the existing tools are broken...does this indicate a need for a clarification?

janlindblad commented 1 month ago

Expressions involving identities and equality also miss out on the extensibility built-in to identities. Designers should use the derived-from* family of functions to compare identities. Whatever we decide, we also need to consider XPath evaluation rules, as we don't want to require tool implementers to implement a bastard version of XPath.

kwatsen commented 1 month ago

Andy: Module designers SHOULD update their modules to always use a prefix (Kent agrees) Jan: be careful changing XPath Andy: should have guidance for compilers to generate warning/errors Rob: should possibly consider replacing XPath Rob: resolution to just update text to provide guidance