mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
535 stars 344 forks source link

Prefix undefined errors are not reported in top level module #743

Closed rabinpatra closed 3 years ago

rabinpatra commented 3 years ago

moduleB that uses a type from another module common is missing the import statement for common.

When module B is compiled, pyang throws an error as expected:

$ pyang -Werror  -f tree -p moduleB.yang

moduleB.yang 
tmp/moduleB.yang:9: error: prefix "common" is not defined (reported only once)
module: moduleB
  +--rw value

However moduleA that imports moduleB and uses its grouping doesn't throw any errors

$ pyang -Werror  -f tree -p moduleA.yang 
module: moduleA
  +--rw value

This causes a lot of problems as errors are obscured from the user and we end up with missing leaves and paths from the final yang model.

Am I missing an option in pyang to perform a stricter check?

Using pyang version 2.4.0

$ pyang  -v
pyang 2.4.0

moduleA.yang.txt moduleB.yang.txt common.yang.txt

mbj4668 commented 3 years ago

If you just validate the module w/o printing the tree you get:

$ pyang moduleA.yang 
moduleB.yang:9: error: prefix "common" is not defined (reported only once)

The tree plugin ignores implict errors b/c often it is better to see the tree even if some imported module has some error.

rabinpatra commented 3 years ago

Thanks for the answer! We started using the validation method in our build.

However -- it might still be useful to print out the implicit parsing problems as warnings.