openconfig / goyang

YANG parser and compiler to produce Go language objects
Apache License 2.0
221 stars 86 forks source link

Cross-Module deviation statement doesn't properly check module prefixes? #214

Open wenovus opened 3 years ago

wenovus commented 3 years ago

Need to write a reproducing YANG file first, but the reported problem is that a deviation without the proper prefix for an element in the path still compiles but shouldn't.

wenovus commented 2 years ago

So I think so this is a low-priority bug. The issue occurs when the prefix after the first element is specified incorrectly, as in this test case in TestDeviation. Given this is a minor bug that pyang already detects, I think it won't have too much of an impact.

                desc: "deviation not supported across modules but prefix unspecified",                                                                                                                                                                                                                                                                     
                inFiles: map[string]string{                                                                                                                                                                                                                                                                                                                
                        "source": `                                                                                                                                                                                                                                                                                                                        
                                module source {                                                                                                                                                                                                                                                                                                            
                                        prefix "s";                                                                                                                                                                                                                                                                                                        
                                        namespace "urn:s";                                                                                                                                                                                                                                                                                                 

                                        container c { leaf a { type string; } }                                                                                                                                                                                                                                                                            
                                        leaf b { type string; }                                                                                                                                                                                                                                                                                            
                                }`,                                                                                                                                                                                                                                                                                                                        
                        "deviation": `                                                                                                                                                                                                                                                                                                                     
                                        module deviation {                                                                                                                                                                                                                                                                                                 
                                                prefix "d";                                                                                                                                                                                                                                                                                                
                                                namespace "urn:d";                                                                                                                                                                                                                                                                                         

                                                import source { prefix s; }                                                                                                                                                                                                                                                                                

                                                deviation /s:c/z:a {                                                                                                                                                                                                                                                                                       
                                                        deviate not-supported;                                                                                                                                                                                                                                                                             
                                                }                                                                                                                                                                                                                                                                                                          
                                        }`,                                                                                                                                                                                                                                                                                                                
                },