CESNET / libyang

YANG data modeling language library
BSD 3-Clause "New" or "Revised" License
368 stars 292 forks source link

Regression on extensions in types referencing typedefs #1994

Closed samuel-gauthier closed 1 year ago

samuel-gauthier commented 1 year ago

Hi!

We have a regression in the unit tests in libyang-python, when using https://github.com/CESNET/libyang/commit/d595eff5e2762d68c23260089872d22315a70202.

Basically, adding a custom extension on a type referencing a typedef is not working anymore. The problem is seen here: https://github.com/CESNET/libyang-python/blob/master/tests/yang/yolo/yolo-system.yang#L68

The custom type is defined here. https://github.com/CESNET/libyang-python/blob/master/tests/yang/wtf/wtf-types.yang#L36

This patch on libyang-python workarounds the error.

diff --git a/tests/yang/yolo/yolo-system.yang b/tests/yang/yolo/yolo-system.yang
index 9ee49f04448f..167961ea5b2a 100644
--- a/tests/yang/yolo/yolo-system.yang
+++ b/tests/yang/yolo/yolo-system.yang
@@ -65,9 +65,7 @@ module yolo-system {
         "An URL.";
       key "proto host";
       leaf proto {
-        type types:protocol {
-          ext:type-desc "<protocol>";
-        }
+        type types:protocol;
       }
       leaf host {
         type string {

To reproduce easily (I'm not sure if some dependencies are needed...):

$ git clone https://github.com/CESNET/libyang-python.git
$ cd libyang-python
$ tox -e lydevel

Thanks!

michalvasko commented 1 year ago

Thanks, should be fixed and I also did some additional refactoring again making the type parsing more organized. Your use-case may have been parsed before but the extensions could not have been compiled correctly.

samuel-gauthier commented 1 year ago

Thanks a lot Michal, the unit tests are working now!