Details
-
Bug
-
Status: Resolved
-
Medium
-
Resolution: Done
-
Sodium SR2
-
None
-
None
-
Linux CentOS 7 / Java 8 update 242
Description
Using : Sodium SR2 ODL release
Receiving HTTP patch response code as 200 when the data validation has failed at cohort level.
Is it correct to have a different HTTP response code other than 200 when there are any cohort validation errors on the server side? This helps HTTP client code to rely on the status code sent by the server.
Followed below steps
- YANG: https://github.com/opendaylight/netconf/blob/master/restconf/restconf-common-models/src/main/yang/instance-identifier-patch-module.yang
- PUT: http://ipaddr:8181/restconf/config/instance-identifier-patch-module:patch-cont/my-list1/vikram
{
"instance-identifier-patch-module:my-list1": [
{
"instance-identifier-patch-module:name": "vikram",
"instance-identifier-patch-module:my-leaf11": "leaf11",
"instance-identifier-patch-module:my-leaf12": "leaf12",
"instance-identifier-patch-module:my-list2": [
{ "instance-identifier-patch-module:name": "Sethu", "instance-identifier-patch-module:my-leaf21": "leaf21", "instance-identifier-patch-module:my-leaf22": "leaf22" }
]
}
]
}
{"ietf-restconf:yang-patch" : {
"patch-id" : "0",
"edit" :[
{ "edit-id" : "edit1", "operation" : "remove", "target" : "/instance-identifier-patch-module:my-list1[instance-identifier-patch-module:name ='vikram']" }
]
}
}
Status code: 200 OK
Response body:
{
"ietf-yang-patch:yang-patch-status": {
"patch-id": "0",
"errors": {
"error": [
{ "error-type": "application", "error-tag": "operation-failed", "error-message": "Deletion Not allowed" }
]
},
"edit-status": {
"edit": [
{ "edit-id": "edit1", "ok": [ null ] }
]
}
}
}
- DELETE: http://ipaddr:8181/restconf/config/instance-identifier-patch-module:patch-cont/my-list1/vikram
{
"errors": {
"error": [
{
"error-type": "application",
"error-tag": "invalid-value",
"error-message": "Deletion Not allowed",
"error-info": "DOMDataTreeIdentifier{datastore=CONFIGURATION, root=/(instance:identifier:patch:module?revision=2015-11-21)patch-cont/my-list1/my-list1[
{(instance:identifier:patch:module?revision=2015-11-21)name=vikram}]}"
}
]
}
}
Status code : 400 Bad request
- Cohort:
public class CrCohort implements DOMDataTreeCommitCohort {
@Override
public FluentFuture<PostCanCommitStep> canCommit( Object txId, SchemaContext ctx,
Collection<DOMDataTreeCandidate> candidates) {
for (DOMDataTreeCandidate candidate : candidates) {
final DataTreeCandidateNode rootNode = candidate.getRootNode();
final Optional<NormalizedNode<?, ?>> dataBefore = rootNode.getDataBefore();
final Optional<NormalizedNode<?, ?>> dataAfter = rootNode.getDataAfter();
ModificationType modificationType = rootNode.getModificationType();
switch (modificationType)
{ *case* *_DELETE_*: *return* FluentFutures._immediateFailedFluentFuture_(*new* DataValidationFailedException( DOMDataTreeIdentifier.*class*, candidate.getRootPath(), "Deletion Not allowed")); *default*: *break*; }}
return PostCanCommitStep.NOOP_SUCCESSFUL_FUTURE;
}
}