[NETCONF-1180] PUT request with insert=after cannot add last item into list Created: 10/Oct/23  Updated: 02/Feb/24

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

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

Attachments: PNG File Created 2 item.png     File PUT requests for Controller.postman_collection.json     PNG File list with one item.png    
Issue Links:
Relates
relates to NETCONF-1163 Create tests for POST "insert" query ... Resolved
relates to NETCONF-1178 POST request with insert parameter fa... In Progress
relates to NETCONF-1177 PUT requests failing with "insert" qu... Confirmed

 Description   

When making a PUT request with `insert=after` query parameter after the last existing one, the request returns a 201 Created status.

However, the newly inserted item does not appear when fetching the data.

Steps to reproduce:
1. Run karaf
2. feature:install odl-restconf-nb odl-netconf-model-rfc8341
3. Use Postman collection to write few items to the list



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

the issue is caused by bad logic of data update, see RestconfStrategy insertWithPoint{Put,Post}

insertion of a new item is performed while iterating through existing elements,
if the index of new item is greater then the list size (insert after last item)
then insert condition condition is never met and actual insert is omitted.

also the update logic seems being not effective, all the list items are beingĀ 
rewritten one by one using tx.replace(), it seems reasonable to update the data
via whole list replacement not item after item. At least start from affected index.

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