[YANGTOOLS-891] LeafRefValidatation can't find target node for relative refs defined in external grouping Created: 24/Jul/18 Updated: 16/Aug/18 Resolved: 02/Aug/18 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | 2.0.9 |
| Fix Version/s: | 2.0.10, 2.0.6.2 |
| Type: | Bug | Priority: | Medium |
| Reporter: | Marek Gradzki | Assignee: | Marek Gradzki |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
LeafRefPatch is built using namespace of the module which contains leafref. org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException: Invalid leafref value [...] allowed values [] for uscase as simple as: bar.yang:
grouping grouping-with-list {
list list-in-grouping {
key "name";
leaf name {
type leafref {
path "../container-in-list/name";
}
}
container container-in-list {
leaf name {
type string;
}
}
}
}
foo.yang:
container foo-top {
uses bar:grouping-with-list;
}
|
| Comments |
| Comment by Marek Gradzki [ 24/Jul/18 ] |
|
Failing unit test (HC): |
| Comment by Marek Gradzki [ 24/Jul/18 ] |
|
It looks like LeafRefValidatation wrongly computes absolute schema node identifier: [...] (urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])afi-safi/ (http://openconfig.net/yang/bgp-multiprotocol?revision=Optional[2015-10-09])config/ (http://openconfig.net/yang/bgp-multiprotocol?revision=Optional[2015-10-09])afi-safi-name for the following augment:
augment /netinst:network-instances/netinst:network-instance/netinst:protocols/netinst:protocol {
uses openconfig-bgp:bgp-top {
augment bgp/neighbors/neighbor/afi-safis/afi-safi {
uses openconfig-bgp:bgp-neighbor-add-paths_config;
}
But according to the https://tools.ietf.org/html/rfc7950#section-7.13: The identifiers defined in the grouping are not bound to a namespace until the contents of the grouping are added to the schema tree via a "uses" statement that does not appear inside a "grouping" statement, at which point they are bound to the namespace of the current module. So correct path should be: [...] (urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])afi-safi/ (urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])config/ (urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])afi-safi-name |
| Comment by Robert Varga [ 27/Jul/18 ] |
|
Looks legit. |
| Comment by Marek Gradzki [ 30/Jul/18 ] |
|
Looks like LeafRefPatch is built using namespace of the module which contains leafref. bar.yang:
grouping grouping-with-list {
list list-in-grouping {
key "name";
leaf name {
type leafref {
path "../container-in-list/name";
}
}
container container-in-list {
leaf name {
type string;
}
}
}
}
foo.yang:
container foo-top {
uses bar:grouping-with-list;
}
|
| Comment by Marek Gradzki [ 30/Jul/18 ] |
|
Fix for the grouping case: |
| Comment by Marek Gradzki [ 30/Jul/18 ] |
|
Unfortunately it does not fully fix the issue with LeafRefValidatation for the BGP data.
Caused by: org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException:
Invalid leafref value [(http://openconfig.net/yang/bgp-types?revision=2015-10-09)IPV4-UNICAST] allowed values [] of LEAFREF node: (urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=2017-12-07)afi-safi-name leafRef target path: Absolute path:/(http://openconfig.net/yang/network-instance?revision=Optional[2015-10-18])network-instances/(http://openconfig.net/yang/network-instance?revision=Optional[2015-10-18])network-instance/(http://openconfig.net/yang/network-instance?revision=Optional[2015-10-18])protocols/(http://openconfig.net/yang/network-instance?revision=Optional[2015-10-18])protocol/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])bgp/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])neighbors/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])neighbor/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])afi-safis/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])afi-safi/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])config/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])afi-safi-name
at org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation.validate0(LeafRefValidatation.java:86) ~[yang-data-impl-2.0.5.jar:na]
at org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation.validate(LeafRefValidatation.java:60) ~[yang-data-impl-2.0.5.jar:na]
at io.fd.honeycomb.data.impl.ModifiableDataTreeManager$ConfigSnapshot.commit(ModifiableDataTreeManager.java:112) ~[data-impl-1.18.10-SNAPSHOT.jar:na]
|
| Comment by Robert Varga [ 31/Jul/18 ] |
|
Can you add a minimal failing test case as a patch, please? |
| Comment by Marek Gradzki [ 01/Aug/18 ] |
|
Sure, but probably no sooner than next week. |
| Comment by Marek Gradzki [ 01/Aug/18 ] |
|
FYI 74630 is self-contained in my opinion. |
| Comment by Robert Varga [ 02/Aug/18 ] |
|
Yeah, please go ahead and open a new one for follow-up. |
| Comment by Marek Gradzki [ 02/Aug/18 ] |
|
Scope of the issue was reduced to the grouping case (see the updated description). Original issue was moved to |
| Comment by Marek Gradzki [ 14/Aug/18 ] |
|
Somewhat simplified version of the issue (now |