There are few inconsistencies and missing features found within the CPS core APIs. This proposal aims to discuss these problems and suggest appropriate solutions for the same. The following list of APIs are found to be impacted by the findings:
Get a node
Update node leaves
Replace a node with descendants
Detailed Analysis
Get a Node
Problem Description:
When a list is fetched using Get a node API then instead of returning one list containing n-number of list items, the API returns n-JSON objects where each object contains one list item each.
For example: if there is a list named "Items" containing 10 items named Item 1, Item 2, ......, Item 10. Then when this list is fetched using get a node API a total of 10 individual JSON objects are returned where each object contains one Item.
To tryout the sample curl requests below please create a simple bookstore entry in your local CPS deployment. Or just execute the following curl request
When updating any data node, it's parent node xpath is provided as part of the update request. And the JSON payload contains the data of child node to be updated.
But due to a user error the parent nodes data can be sent as part of the JSON payload and even then, instead of failing the request is successfully executed with partial update Where only the child data node is updated, and the parent data node is not updated.
The expected behavior should be to throw an exception as the Update a node API requires parent node xpath to update any child data. Which in this case should be "/bookstore" because the request is also updating the node with key "code=1"
This situation can mainly occur due to user error, where user provides updated parent data along with parent node xpath as part of the request.
If a replace operation is performed on a list, where a new list item is also added to the list, then it results in a 200-response code, with a partial replace operation.