06-26-2025 02:08 AM
New pyang version produces a warning if when statements are checking operational data (config false)
... "is config false and is not part of the accessible tree"
https://github.com/mbj4668/pyang/issues/918
I have a setup with:
config false and
tailf:cdb-oper {
tailf:persistent true;
}
It seems to work fine in NSO 6.3.8.1
is this something that will continue to work in NSO and we can ignore this warning or is it something that will stop working in the future?
Solved! Go to Solution.
06-26-2025 04:10 AM
While you will continue to be able to do this, it is recommended against as it is not allowed per this section of RFC 7950 - The YANG 1.1 Data Modeling Language :
The accessible tree depends on where the statement with the XPath
expression is defined:
o If the XPath expression is defined in a substatement to a data
node that represents configuration, the accessible tree is the
data in the datastore where the context node exists. The root
node has all top-level configuration data nodes in all modules as
children.
And https://datatracker.ietf.org/doc/html/rfc7950#section-8.1
o If the constraint is defined on configuration data, it MUST be true in a valid configuration data tree.
You can continue to ignore the warnings, but it may not be a good idea - if a when
expression (or must
expression or leafref
path) for config references state data, it means that the validity of the configuration depends on state, and thus that a validated and committed configuration can become invalid if some state data is changed (this is of course the reason for the requirements in the RFCs).
06-26-2025 04:10 AM
While you will continue to be able to do this, it is recommended against as it is not allowed per this section of RFC 7950 - The YANG 1.1 Data Modeling Language :
The accessible tree depends on where the statement with the XPath
expression is defined:
o If the XPath expression is defined in a substatement to a data
node that represents configuration, the accessible tree is the
data in the datastore where the context node exists. The root
node has all top-level configuration data nodes in all modules as
children.
And https://datatracker.ietf.org/doc/html/rfc7950#section-8.1
o If the constraint is defined on configuration data, it MUST be true in a valid configuration data tree.
You can continue to ignore the warnings, but it may not be a good idea - if a when
expression (or must
expression or leafref
path) for config references state data, it means that the validity of the configuration depends on state, and thus that a validated and committed configuration can become invalid if some state data is changed (this is of course the reason for the requirements in the RFCs).
06-26-2025 04:22 AM
Ok, good to know the reasoning behind it and as such we shouldn't have a generic ignore of such warnings.
In this case it would probably be fine since I'm using the when expression to show/hide a grouping of actions that are only relevant during some operational conditions.
06-26-2025 09:10 AM
If all that is there are actions then maybe this does not need to be config data. Maybe if you have a when on the enclosing container, all you need is to add 'config false' on that container.
06-26-2025 10:58 PM
All that is controlled by the when statement is actions.
Enclosing it inside a container wouldn't change much since we want to control it related to a specific value/state in a oper leaf.
It would give us the option to create/delete that container as we change the state of the oper leaf, but I think currently we prefer the actions to be on top level rather then inside a container
06-27-2025 12:29 AM
06-27-2025 12:39 AM
Actions do not allow when statements inside them, so the way I did it is to create a grouping with only the actions defined inside it.
Then in the uses statement where I bring the grouping in I can place the when expression there.
Hence compiler probably has a hard time to determine if when expression can be safe or not
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide