[NETCONF-985] Incorrect processing of RESTCONF fields for duplicate node names on NETCONF device Created: 28/Mar/23 Updated: 01/Jun/23 Resolved: 01/Jun/23 |
|
| Status: | Resolved |
| Project: | netconf |
| Component/s: | restconf-nb |
| Affects Version/s: | 3.0.9, 4.0.5, 5.0.4 |
| Fix Version/s: | 6.0.0, 5.0.7, 4.0.8 |
| Type: | Bug | Priority: | Medium |
| Reporter: | Sangwook Ha | Assignee: | Sangwook Ha |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
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). |
| Comments |
| Comment by Sangwook Ha [ 28/Mar/23 ] |
|
The data structure used for the fields parameter (a set for each depth level) would also affect the request for MDSAL datastore but in a different way - controller may return unintended data nodes since data node at a given depth is included if its QName is included in the set for the depth. |