[NETCONF-678] HTTP PATCH response code is 200 on DataValidationFailedException on server Created: 28/Apr/20 Updated: 16/Nov/21 Resolved: 16/Nov/21 |
|
| Status: | Resolved |
| Project: | netconf |
| Component/s: | restconf-nb |
| Affects Version/s: | Sodium SR2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Medium |
| Reporter: | Vikram Darsi | Assignee: | Ivan Martiniak |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
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
{ "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 ] } ] } } }
{ "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
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; } } |
| Comments |
| Comment by Ivan Martiniak [ 16/Nov/21 ] |
|
Bug is no longer actual as code has shifted, after reproducing it in affected version Sodium SR2. |