You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
YANG when statements (RFC 7950 §7.21.5) attach a conditional xpath expression to a node — the node only exists in the data tree if the expression evaluates to true. Neither the schema-server nor the data-server currently implement when evaluation.
What needs to happen
schema-server (prerequisite)
The schema-server must:
Serialise the when xpath string from yang.Entry.When.Name into the schema proto so data-server can retrieve it
Apply import-alias prefix normalisation to the xpath before serialising it — identical to the rewrite already implemented for must statements. When a module imports an identity module under a local alias different from the declared prefix, quoted literals like 'alias-id:BGP' must be rewritten to 'declared-prefix:BGP'. The normalizeXPathLiterals helper in pkg/schema/leaf.go is directly reusable for this. See Normalise import-alias prefixes in 'when' xpath expressions schema-server#240 for details on this specific requirement.
data-server
The data-server must:
Retrieve the normalised when xpath string from the schema proto
Evaluate it during validation / tree operations against the current data tree context
Exclude nodes whose when condition evaluates to false (node non-existence semantics per RFC 7950)
Notes
when evaluation context follows RFC 7950 §7.21.5: the context node is the node carrying the when, the accessible tree is the full data tree
when on a uses/augment node has slightly different context rules (§7.21.5 "context node" note) — worth scoping carefully
The xpath evaluator already used for must should be reusable here
Prefix normalisation in the schema-server is a hard prerequisite for correct evaluation of identity-valued comparisons in when expressions
Background
YANG
whenstatements (RFC 7950 §7.21.5) attach a conditional xpath expression to a node — the node only exists in the data tree if the expression evaluates to true. Neither the schema-server nor the data-server currently implementwhenevaluation.What needs to happen
schema-server (prerequisite)
The schema-server must:
whenxpath string fromyang.Entry.When.Nameinto the schema proto so data-server can retrieve itmuststatements. When a module imports an identity module under a local alias different from the declared prefix, quoted literals like'alias-id:BGP'must be rewritten to'declared-prefix:BGP'. ThenormalizeXPathLiteralshelper inpkg/schema/leaf.gois directly reusable for this. See Normalise import-alias prefixes in 'when' xpath expressions schema-server#240 for details on this specific requirement.data-server
The data-server must:
whenxpath string from the schema protowhencondition evaluates to false (node non-existence semantics per RFC 7950)Notes
whenevaluation context follows RFC 7950 §7.21.5: the context node is the node carrying thewhen, the accessible tree is the full data treewhenon a uses/augment node has slightly different context rules (§7.21.5 "context node" note) — worth scoping carefullymustshould be reusable herewhenexpressions