ConfD User Community

Yang compilation fails


#1

Hi, I am getting the following error on compilation:

eci-bgp-l3vpn-dev.yang:56: error: the type leafref (defined at ./ietf-interfaces.yang:54) is converted to 'string' when part of a union

The following are the related yang files:

ietf-interfaces.yang

typedef interface-ref {
    type leafref {
      path "/if:interfaces/if:interface/if:name";
    }

eci-bgp-l3vpn-dev.yang

   typedef lif-type {
                 type union {
                            type if:interface-ref;
                            type string ;  
                            }
                     }  

What is the issue here?
Please assist.

Thanks in advance.


#2

It’s actually a warning, but I guess you use --fail-on-warnings, which is generally a Good Idea™.

You have encountered one of the exceptions in the YANG 1.1 support - from the “YANG 1.1” section of the confdc(1) manual page:

o   Type leafref in unions are not validated, and treated as a string
    internally.

(In YANG 1, type leafref is not allowed to be part of a union.)

You can prevent the warning from becoming an error when you use --fail-on-warnings by passing -W YANG_ERR_UNSUPPORTED_TYPE_IN_UNION to confdc, or you can suppress even the warning by passing -w YANG_ERR_UNSUPPORTED_TYPE_IN_UNION.


#3

Hi,

Thanks for the suggestion. I added this -W YANG_ERR_UNSUPPORTED_TYPE_IN_UNION to confdcbut it not work. The compilation failed with the same error.

I also removed --fail-on-warnings and yet got the same message.
Doesn’t this mean that it is an error and not warning?

How should I approach this issue?

Thanks,
Ramakrishnan


#4

I’m afraid you must be making some mistake when changing the compilation options - maybe you have some generic make target that is applied? I verified what I wrote before posting - here it is, where I faked your eci-bgp-l3vpn-dev.yang module as containing only the typedef, and used ietf-interfaces revision 2014-05-08:

$ confdc -c eci-bgp-l3vpn-dev.yang
eci-bgp-l3vpn-dev.yang:12: warning: the type leafref (defined at ./ietf-interfaces@2014-05-08.yang:54) is converted to 'string' when part of a union
$ echo $?
0
$ confdc -c --fail-on-warnings eci-bgp-l3vpn-dev.yang
eci-bgp-l3vpn-dev.yang:12: error: the type leafref (defined at ./ietf-interfaces@2014-05-08.yang:54) is converted to 'string' when part of a union
$ echo $?
1
$ confdc -c --fail-on-warnings -W YANG_ERR_UNSUPPORTED_TYPE_IN_UNION eci-bgp-l3vpn-dev.yang
eci-bgp-l3vpn-dev.yang:12: warning: the type leafref (defined at ./ietf-interfaces@2014-05-08.yang:54) is converted to 'string' when part of a union
$ echo $?
0
$ confdc -c --fail-on-warnings -w YANG_ERR_UNSUPPORTED_TYPE_IN_UNION eci-bgp-l3vpn-dev.yang
$ echo $?
0
$

#5

Thanks a lot for looking into this.

I have something like this,
../../cml/confd/kvm/Confd/bin/confdc -c --deviation eci-bgp-l3vpn-dev.yang -o eci-bgp-l3vpn-dev.fxs --verbose --fail-on-warnings -w YANG_ERR_UNSUPPORTED_TYPE_IN_UNION eci-bgp-l3vpn.yang

Do you see any issues with the above?

Thanks in advance.


#6

Hi,

There was one more place where this flag was needed.
Added it and now it works fine.

Thanks!


#7

Good to hear! About the confdc command you quoted, it’s a bit weird in that you are compiling eci-bgp-l3vpn.yang but request that the fxs file should be called eci-bgp-l3vpn-dev.fxs. In principle you can call the fxs files whatever you want, but it gets confusing if they don’t match the .yang name - and in some cases you actually need to compile and load deviation modules “themselves”.