libyang icon indicating copy to clipboard operation
libyang copied to clipboard

yanglint can't find absolute path leafref target when defined within sx:augment-structure

Open ksallberg opened this issue 10 months ago • 1 comments

Reproducible with: yanglint 3.7.8

This YANG should be valid AFAICT but yanglint can't find the leafref's target:

module example {
  yang-version 1.1;
  namespace "ex:ample";
  prefix example;

  import ietf-yang-structure-ext {
    prefix sx;
  }

  container files {
    list file {
      key id;

      leaf id {
        type uint32;
      }
    }
  }

  sx:structure struct {
    container c {
    }
  }

  sx:augment-structure "/example:struct/c" {
    leaf id {
      type leafref {
        path "/example:files/example:file/example:id";
      }
    }
  }
}

yanglint example.yang libyang err : Not found node "files" in path. (/example:c/id)

ksallberg avatar Mar 31 '25 13:03 ksallberg

I do not think standard YANG nodes are accessible from structures and vice versa, for XPath purposes based on the following text from ietf-yang-structure-ext:

       The XPath document element is the extension statement itself,
       such that the child nodes of the document element are
       represented by the data-def-stmt substatements within this
       extension.  This conceptual document is the context for the
       following YANG statements:

         - must-stmt
         - when-stmt
         - path-stmt
         - min-elements-stmt
         - max-elements-stmt
         - mandatory-stmt
         - unique-stmt
         - ordered-by
         - instance-identifier data type

michalvasko avatar Apr 04 '25 06:04 michalvasko