Details
-
Bug
-
Status: Resolved
-
Resolution: Cannot Reproduce
-
None
-
None
-
None
-
None
-
Operating System: All
Platform: All
-
8887
Description
I am using yangtools boron-sr4. I think the validate rules of "min-elements" is not consistent with the RFC6020.
See https://tools.ietf.org/html/rfc6020#page-63
7.7.3. The min-elements Statement
If "min-elements" exists in the leaf-list or list, and the leaf-list's or list's closest ancestor node is neither a non-presence container nor a case node. The "min-elements" constraint is enforced if the ancestor node exists.
But in fact the yang-data-impl's rule is like this:
if (constraints.isMandatory() || (minElements != null && minElements > 0)) {
final YangInstanceIdentifier childId = id.node(NodeIdentifier.create(child.getQName()));
LOG.debug("Adding mandatory child {}", childId);
builder.add(childId.toOptimized());
} }
}
It means that if "min-elements" is exist, the list or leaf-list node must exist.
Consider a yang module like this:
list layer-protocol {
container eth-cep-pac {
list vlan-spec
leaf mac-adress-learning-range
{ type uint64; }}
container eth-nep-pac {
leaf total-potential-eth-capacity { type uint64; }
leaf available-eth-capacity
{ type uint64; } }
}
If I put "layer-protocol" without "eth-cep-pac" into configuration datastoreļ¼ IllegalArgumentException occurred " missing mandatory descendant /eth-cep-pac/vlan-spec"