Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The idea here is to have a mechanism to validate the data and throw an appropriate response with message, before without the data is being persisted in the database. This validation check is not meant to be limited for to new data but should also extend to sub-sets of a larger data set, such as data used in case of an update operation. So based on this the following approaches are proposed to perform a validation on data:

...

  • Response Code: 400
  • Response Body: a JSON response providing details about the failure. (response body format to be finalized)

List of impacted APIs if dry-run flag is introduced


NameEndpointIssueRequired Action
1Create a Node/{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodesReturns 500 status on data validation failure

Return 400 status with updated and detailed error message.

Updated Message:

Code Block
{
"status": "400 BAD_REQUEST",
"message": "Data Validation Failed",
"Schema node with name "Node" was not found 
under (urn:ietf:params:xml:ns:netconf:base:1.0)data." 
}


2Update Node Leaves/{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodesReturns 400 status with entire JSON payload in error message
3Replace Nodes/{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodesReturns 400 status with entire JSON payload in error message
4Add List Element/{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/list-nodesReturns 500 status on data validation failure
5Replace List element/{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/list-nodesReturns 400 status with entire JSON payload in error message

...

would return a 500-response code in case of Data Validation failure. This is in clear contradiction to the details mentioned in CPS Exceptions and REST APIs HTTP Response Codes documentation. This has been identified as a bug and was fixed in the following patch Fix "Create a node" and "Add List Elements" APIs response code · Gerrit Code Review.

...