diff --git a/src/sonic-yang-mgmt/sonic_yang.py b/src/sonic-yang-mgmt/sonic_yang.py index ffc2e687ea9..ba982f8556e 100644 --- a/src/sonic-yang-mgmt/sonic_yang.py +++ b/src/sonic-yang-mgmt/sonic_yang.py @@ -526,7 +526,7 @@ def find_data_dependencies(self, data_xpath): schema_node = ly.Schema_Node_Leaf(data_node.schema()) backlinks = schema_node.backlinks() - if backlinks.number() > 0: + if backlinks is not None and backlinks.number() > 0: for link in backlinks.schema(): node_set = node.find_path(link.path()) for data_set in node_set.data(): diff --git a/src/sonic-yang-mgmt/tests/libyang-python-tests/test_SonicYang.json b/src/sonic-yang-mgmt/tests/libyang-python-tests/test_SonicYang.json index f3e0c46f76b..aba9ced2cc8 100644 --- a/src/sonic-yang-mgmt/tests/libyang-python-tests/test_SonicYang.json +++ b/src/sonic-yang-mgmt/tests/libyang-python-tests/test_SonicYang.json @@ -59,10 +59,12 @@ "dependencies":[ {"xpath":"/test-port:port/PORT/PORT_LIST[port_name='Ethernet8']/port_name", - "dependencies": - ["/test-acl:acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='PACL-V6']/ports[.='Ethernet8']", - "/test-interface:interface/INTERFACE/INTERFACE_LIST[interface='Ethernet8'][ip-prefix='10.1.1.64/26']/interface", - "/test-interface:interface/INTERFACE/INTERFACE_LIST[interface='Ethernet8'][ip-prefix='2000:f500:40:a749::/126']/interface"]} + "dependencies": + ["/test-acl:acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='PACL-V6']/ports[.='Ethernet8']", + "/test-interface:interface/INTERFACE/INTERFACE_LIST[interface='Ethernet8'][ip-prefix='10.1.1.64/26']/interface", + "/test-interface:interface/INTERFACE/INTERFACE_LIST[interface='Ethernet8'][ip-prefix='2000:f500:40:a749::/126']/interface"]}, + {"xpath":"/test-port:port/PORT/PORT_LIST[port_name='Ethernet8']/alias", + "dependencies":[]} ], "schema_dependencies":[ {"xpath":"/test-port:port/test-port:PORT/test-port:PORT_LIST/test-port:port_name",