Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-983

Extensions nested in enums cause a failure to assemble SchemaContext

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: High High
    • 3.0.1
    • None
    • parser
    • None

      The following construct:

                  leaf pc-speed {
                      tailf:alt-name "speed";
                      tailf:info "Configure speed operation.";
                      description "Configure speed operation.";
                      type enumeration {
                          enum "10" {
                              tailf:info "Force 10 Mbps operation";
                          }
                          enum "100" {
                              tailf:info "Force 100 Mbps operation";
                          }
                          enum "1000" {
                              tailf:info "Enable AUTO speed configuration";
                          }
                          enum "nonegotiate" {
                              //FIXME
                          }
                          enum "auto" {
                              tailf:info "Enable AUTO speed configuration";
                          }
                      }
                  }
      

      causes a failure to assemble:

      07:57:59 Caused by: java.lang.IllegalArgumentException: String '10' is not a valid identifier
      07:57:59     at com.google.common.base.Preconditions.checkArgument (Preconditions.java:217)
      07:57:59     at org.opendaylight.yangtools.yang.common.AbstractQName.checkLocalName (AbstractQName.java:69)
      07:57:59     at org.opendaylight.yangtools.yang.common.QName.create (QName.java:125)
      07:57:59     at org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.internedQName (StmtContextUtils.java:576)
      07:57:59     at org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.qnameFromArgument (StmtContextUtils.java:499)
      07:57:59     at org.opendaylight.yangtools.yang.parser.stmt.reactor.SubstatementContext.createSchemaPath (SubstatementContext.java:154)
      07:57:59     at org.opendaylight.yangtools.yang.parser.stmt.reactor.SubstatementContext.getSchemaPath (SubstatementContext.java:176)
      07:57:59     at org.opendaylight.yangtools.yang.parser.rfc7950.stmt.extension.UnrecognizedEffectiveStatementImpl.<init> (UnrecognizedEffectiveStatementImpl.java:49)
      07:57:59     at org.opendaylight.yangtools.yang.parser.rfc7950.stmt.extension.UnrecognizedStatementSupport.createEffective (UnrecognizedStatementSupport.java:41)
      07:57:59     at org.opendaylight.yangtools.yang.parser.rfc7950.stmt.extension.ModelDefinedStatementSupport.createEffective (ModelDefinedStatementSupport.java:42)
      07:57:59     at org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase.buildEffective (StatementContextBase.java:485)

      This is cause by the assumption that each statement has to have a SchemaPath, which is composed of QNames. This used to work as long as QName allowed non-identifiers to be present in localName, but was fragile anyway – in this particular case it was allowed, but the same thing would have happened if the enum argument would have any of forbidden characters in it.

            rovarga Robert Varga
            rovarga Robert Varga
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: