Uploaded image for project: 'netconf'
  1. netconf
  2. NETCONF-985

Incorrect processing of RESTCONF fields for duplicate node names on NETCONF device

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Medium Medium
    • 6.0.0, 5.0.7, 4.0.8
    • 3.0.9, 4.0.5, 5.0.4
    • restconf-nb
    • None

      NetconfFieldsTranslator fails to generate the correct data tree paths for the fields parameter which includes data paths with data nodes with the same name at the same depth.

      For example, with the following data model:

      module foo {
        namespace "urn:foo";
        prefix "foo";
      
        container foo {
          container bar {
            leaf alpha {
              type string;
            }
            container beta {
              leaf gamma {
                type string;
              }
              leaf delta {
                type string;
              }
            }
          }
      
          list baz {
            key alpha;
            leaf alpha {
              type string;
            }
            container beta {
              leaf gamma {
                type string;
              }
              leaf epsilon {
                type string;
              }
            }
          }
        }
      }
      

      A request for the path /foo:foo with the following fields parameter

      bar(alpha;beta/gamma);baz(alpha;beta/gamma)
      

      generates the following NETCONF subtree filter:

      <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
          <foo xmlns="urn:foo">
              <bar>
                  <beta>
                      <gamma/>
                  </beta>
                  <alpha/>
              </bar>
              <baz/>
          </foo>
      </filter>
      

      Note that the request does not specify alpha & beta/gamma under baz. Instead it is requesting the whole subtree for baz.

      Another request for the path /foo:foo with the following fields parameter

      bar(alpha;beta/delta);baz(alpha;beta/epsilon)
      

      returns 500 error with the following error message:

      Caused by: java.lang.IllegalArgumentException: Supplied QName (urn:foo)epsilon is not valid according to schema EmptyContainerEffectiveStatement{argument=(urn:foo)beta}, potential children nodes: [EmptyLeafEffectiveStatement{argument=(urn:foo)gamma}, EmptyLeafEffectiveStatement{argument=(urn:foo)delta}]
      	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:453) ~[?:?]
      	at org.opendaylight.netconf.util.StreamingContext.fromSchemaAndQNameChecked(StreamingContext.java:58) ~[?:?]
      	at org.opendaylight.netconf.util.StreamingContext$AbstractDataContainer.fromLocalSchema(StreamingContext.java:242) ~[?:?]
      	at org.opendaylight.netconf.util.StreamingContext$AbstractDataContainer.getChild(StreamingContext.java:231) ~[?:?]
      	at org.opendaylight.netconf.util.StreamingContext$AbstractComposite.getChildOperation(StreamingContext.java:207) ~[?:?]
      	at org.opendaylight.netconf.util.StreamingContext$AbstractComposite.emitChildTreeNode(StreamingContext.java:189) ~[?:?]
      	at org.opendaylight.netconf.util.StreamingContext$AbstractComposite.streamToWriter(StreamingContext.java:182) ~[?:?]
      	at org.opendaylight.netconf.util.StreamingContext$AbstractComposite.emitChildTreeNode(StreamingContext.java:189) ~[?:?]
      	at org.opendaylight.netconf.util.StreamingContext$AbstractComposite.streamToWriter(StreamingContext.java:182) ~[?:?]
      	at org.opendaylight.netconf.util.StreamingContext$AbstractComposite.emitChildTreeNode(StreamingContext.java:189) ~[?:?]
      	at org.opendaylight.netconf.util.StreamingContext$AbstractComposite.streamToWriter(StreamingContext.java:182) ~[?:?]
      	at org.opendaylight.netconf.util.NetconfUtil.writeFilter(NetconfUtil.java:305) ~[?:?]
      

      The error message indicates that a path generated from the fields parameter does not conform to the data model.

      The reason why fields parameters like this fail is because the data node identifiers are saved in a set for each depth level while processing the parameter in NetconfFieldsTranslator. Hence if there are multiple data nodes with the same name at the same depth only one of them is saved in the set, and either some of the paths are not generated (the first case) or may lead to incorrect path (the second case).

            sangwookha Sangwook Ha
            sangwookha Sangwook Ha
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: