Uploaded image for project: 'netconf'
  1. netconf
  2. NETCONF-678

HTTP PATCH response code is 200 on DataValidationFailedException on server

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Medium
    • Resolution: Done
    • Sodium SR2
    • None
    • restconf-nb
    • 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 

      1. YANG: https://github.com/opendaylight/netconf/blob/master/restconf/restconf-common-models/src/main/yang/instance-identifier-patch-module.yang
      2. 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"         }

            ]

          }

        ]

      }

      1. PATCH:  http://ipaddr:8181/restconf/config/instance-identifier-patch-module:patch-con

      {"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                     ]                 }

                  ]

              }

          }

      }

       

      1. 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

      1. 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;

          }

      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ivanm1996 Ivan Martiniak
            vikram_darsi Vikram Darsi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: