[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:
Blocks
blocks YANGTOOLS-892 LeafRefValidatation can't find target... Resolved

 Description   

LeafRefPatch is built using namespace of the module which contains leafref.
Such approach probably originates from --YANGTOOLS-749--, but fails with

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):
https://gerrit.fd.io/r/#/c/13292/2/infra/bgp-distribution-test/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java

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.
Such approach probably originates from YANGTOOLS-749, but fails 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;
    }
Comment by Marek Gradzki [ 30/Jul/18 ]

Fix for the grouping case:

https://git.opendaylight.org/gerrit/#/c/74630/

Comment by Marek Gradzki [ 30/Jul/18 ]

Unfortunately it does not fully fix the issue with LeafRefValidatation for the BGP data.
Target path is now correct, but set of allowed values is still empty:

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.
I can create another ticket for the grouping case if you want.

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 YANGTOOLS-892.

Comment by Marek Gradzki [ 14/Aug/18 ]

Somewhat simplified version of the issue (now YANGTOOLS-892) with failing test case:

https://git.opendaylight.org/gerrit/#/c/75190/ 

Generated at Wed Feb 07 20:54:36 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.