Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Use Discussion notes to capture meeting items, assign owners, and track actions and decisions.

Date

Item

Owner

Notes

Relevant Links

@someone

  • Action

    Problem Statement

    The Replace Node Leaves API can only perform a replace operation on one data node at a time and in order to perform this request the user needs to provide the following parameters as part of the request:

    • the parent node xpath of the node being replaced

    • the JSON/XML payload containing the new data which will replace the existing data.

    Scenario 1: API accepts new list items

    If a replace operation is performed on a list node, where an already existing list item is being replaced, then in this scenario a user induced error can take place where the user can send a new list item as part of the payload.

    This results in a 200-response code being returned to the user but with a partial replace operation.

    Because when the data is verified after the replace operation is executed, it is seen that the data of existing list item is replaced, which is the expected behavior. But the data of the new list item is not added under the list node.

    But since the API returns a 200-response code, it could create a false sense of security for the user that the request executed successfully, where in fact only a partial operation took place in the database.

    A more detailed explanation with examples is as follows:

    1. In the following data, the node titled “Matilda",under the list named “books",is to be replaced.
     Click here to expand...
    {
      "book-store:categories": {
        "code": "1",
        "name": "Kids",
        "books": [
          {
            "title": "Matilda",
            "lang": "English",
            "authors": ["Roald Dahl"],
            "editions": [2024]
          }
        ]
      }
    }
    2. In order to do so the correct parent node xpath and JSON payload would be as follows:
     Click here to expand...

    Correct parent node xpath: /bookstore/categories[@code=1]

    Correct JSON payload:

    {
      "books": [
        {
          "title": "Matilda",
          "lang": "French",
          "editions": [2025]
        }
      ]
    }
    3. API accepts extra/new list elements as part of request

    If the user modifies an existing list item and along with that adds a new list item in the payload then once the request is executed the user receives a 200-response code. But upon verifying the data after the request is executed it is seen that only

     Click here to expand...

    Correct parent node xpath: /bookstore/categories[@code=1]

    Incorrect JSON payload with newly added list item with title: Book 2

    {
      "books": [
        {
          "title": "Matilda",
          "lang": "French",
          "editions": [2025]
        },
        {
          "title": "Book 2",
          "lang": "English",
          "authors": ["Test"],
          "editions": [2000]
        }
      ]
    }
    4. The data queried after the above replace operation is executed is as follows:
     Click here to expand...
    [
      {
        "book-store:books": {
    	  "title": "Matilda",
          "lang": "French",
          "authors": ["Roald Dahl"],
          "editions": [2025]
        }
      }
    ]

    It can be seen that only the existing list item, i.e. title: Matilda is replaced. Whereas the newly added list item with title: Book 2 is not added but user received a 200-response code.

    Scenario 2: API executes the request with incorrect payload

    Another user induced error can occur when the user tries to make changes to the key leaf node, which in the current example is "title". If the key is modified, for example title "Matilda" changed to "Incorrect Book Name", the request should fail because there is no such node present in the database.

    But if such an error is intentionally induced to test the functionality of the API, it is seen that the request gets executed with an incorrect payload and the user receives a 200-response code.

     Click here to expand...

    Correct parent node xpath: /bookstore/categories[@code=1]

    Incorrect JSON payload with misspelled key node, i.e. title

    {
      "books": [
        {
          "title": "Incorrect Book Name",
          "lang": "French",
          "editions": [2025]
        }
      ]
    }

    Proposed Solutions

    • No labels