[NETCONF-1178] POST request with insert parameter fails if target URI points the list Created: 05/Oct/23  Updated: 24/Nov/23

Status: In Progress
Project: netconf
Component/s: None
Affects Version/s: None
Fix Version/s: 7.0.0

Type: Bug Priority: Medium
Reporter: Yaroslav Lastivka Assignee: Samuel Schneider
Resolution: Unresolved Votes: 0
Labels: pick-next, pt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File user-ordered-list@2023-10-04.yang    
Issue Links:
Relates
relates to NETCONF-1163 Create tests for POST "insert" query ... Resolved
relates to NETCONF-1180 PUT request with insert=after cannot ... Confirmed
relates to NETCONF-1177 PUT requests failing with "insert" qu... Confirmed

 Description   

POST requests inherently operate on parent resources in the path. This makes it impossible to utilize the `insert` query parameter in the desired manner.
When the parent resource root (which is a container) is used, the application assigns the insert parameter to the container, rather than to the child list items which we intend to update.
Example

curl --location --request POST 'http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=17830-sim-device/yang-ext:mount/user-ordered-list:root?insert=last' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--header 'Cookie: JSESSIONID=node01orql8nxe3xvz18848b91d7c1z1.node0' \
--data-raw '{
  "user-ordered-list:items": [
    {
      "id": 1,
      "name": "name"
    }
  ]
}'

Error Received:

{
    "errors": {
        "error": [
            {
                "error-tag": "bad-element",
                "error-message": "Insert parameter can be used only with list or leaf-list",
                "error-type": "protocol"
            }
        ]
    }
}

A similar situation arises when using a list as the parent resource. In this case, the application assigns the insert parameter to the parent list and demands an ordered-by-user statement.



 Comments   
Comment by Ruslan Kashapov [ 15/Nov/23 ]

seems copy paste issue from PUT case

see RestconfStrategy.java#L386

the path already points to parent element, no reason taking parent of parent,
the inserted item path value expected to be calculated based on URI path value, not takes as is.
the subsequent logic #insertAndCommitPost() should be updated accordingly.

Generated at Wed Feb 07 20:16:52 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.