libyang icon indicating copy to clipboard operation
libyang copied to clipboard

failed to sx:augment-structure directly under sx:structure

Open mrdotchenke opened this issue 1 year ago • 1 comments

Version: libyang 3.7.8

There are two modules, the module a defined sx:structure called "struct"

module a {
  yang-version 1.1;
  namespace urn:tests:extensions:structure:a;
  prefix a;
  import ietf-yang-structure-ext {
    prefix sx;
  }
  sx:structure struct {
    container n1 {
      leaf l {
        type uint32;
      }
    }
  }
}

And the module b defined sx:augment-structure to directly augment an leaf under the "/a:struct"

module b {
  yang-version 1.1;
  namespace urn:tests:extensions:structure:b;
  prefix b;
  import ietf-yang-structure-ext {
    prefix sx;
  }
  import a {
    prefix a;
  }
  sx:augment-structure "/a:struct" {
    leaf aug-leaf {
      type string;
    }
  }
}

When call lys_parse_mem with module b, after module a was successful loaded, would got an error:

libyang[0]: Augment extension target node "/a:struct" from module "b" was not found. (schemadata path: /b:{extension='sx:augment-structure'}/{augment='/a:struct'})

mrdotchenke avatar Jan 17 '25 09:01 mrdotchenke

Based on the extension definition, I believe, you must target an actual data node, the structure itself is not allowed (it would result in "top-level" augment nodes). So try using

sx:augment-structure "/a:struct/a:n1" {
   ...

michalvasko avatar Jan 17 '25 12:01 michalvasko