libyang icon indicating copy to clipboard operation
libyang copied to clipboard

limitation of extension plugins

Open rkrejci opened this issue 2 years ago • 0 comments

Currently, the (internal) extension plugins check for the correct placing of the extension instances. This is done in the compile callback. The limitation of this approach is that not all the statements are actually compiled. For example typedef or import, so the following module is parsed successfully by yanglint despite the internal metadata plugin checks for placing annotation statement only in top level.

module x {
  namespace test:x;
  prefix x;

  import ietf-yang-metadata {prefix md;}
  import ietf-yang-types {prefix yt; md:annotation xxx;}

  typedef mytype {
    type int8;
    md:annotation yyy;
  }
}

I don't think it has a big impact, but at least it should be mentioned as a "known bug/limitation". The best solution would be to separate these checks into a separated callback used by parsers, but I'm afraid that in that time the extension instance is not yet connected with the extension definition and the extension plugin. So I don't see a simple solution.

rkrejci avatar Mar 12 '22 19:03 rkrejci