[NETCONF-937] Error writing values with XML YANG Patch Created: 04/Jan/23 Updated: 24/Jan/23 Resolved: 24/Jan/23 |
|
| Status: | Resolved |
| Project: | netconf |
| Component/s: | restconf-nb |
| Affects Version/s: | None |
| Fix Version/s: | 5.0.1 |
| Type: | Bug | Priority: | High |
| Reporter: | Peter Suna | Assignee: | Peter Suna |
| Resolution: | Done | Votes: | 0 |
| Labels: | pt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
Invoking YANG Patch with XML payload (PATCH http://192.168.56.25:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=17830-sim-device/yang-ext:mount/instance-identifier-patch-module:patch-cont/my-list1=leaf1): <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch"> <patch-id>test-patch</patch-id> <comment>this is test patch</comment> <edit> <edit-id>edit1</edit-id> <operation>replace</operation> <target>/my-leaf11</target> <value> <my-leaf11>my-leaf11 :: XML value</my-leaf11> </value> </edit> </yang-patch> Results in error and leaf value is not written:
{
"errors": {
"error": [
{
"error-tag": "malformed-message",
"error-message": "Error parsing input: null",
"error-type": "protocol"
}
]
}
}
Corresponding payload in JSON works. |
| Comments |
| Comment by Ivan Hrasko [ 05/Jan/23 ] |
|
XmlPatchBodyReader contains redundant if condition which is not in JsonPatchBodyReader. if (schemaNode instanceof ContainerSchemaNode || schemaNode instanceof ListSchemaNode) { final NormalizedNodeResult resultHolder = new NormalizedNodeResult(); final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder); final XmlParserStream xmlParser = XmlParserStream.create(writer, inference); xmlParser.traverse(new DOMSource(firstValueElement)); parsed = resultHolder.getResult(); } else { parsed = null; } This if condition causes that ChoiceSchemaNode, LeafListSchemaNode, etc. will not be parsed: JsonPatchBodyReader does not contain this condition before parsing patch value: Therefore, this condition in XmlPatchBodyReader is redundant and should be removed. |