Some edits to the list of tools that modify the indices of the remaining items in the list result in unexpected behavior of the /api/lists/{list_pk}/revisions/{id}/diff/{other_id}/ endpoint.
Example:
- Initial list [tool1, tool2, tool3]
- Remove tool1 and tool2
- Updated list is now [tool3]
The api returns the following operations:
"operations": [ { "op": "remove", "path": "/tools/0" }, { "op": "remove", "path": "/tools/0" } ], Expected behavior: "operations": [ { "op": "remove", "path": "/tools/0" }, { "op": "remove", "path": "/tools/1" } ], }
There is a certain "logic" behind this behavior if you consider the operations as sequential, i.e. when the first tool at index 0 is removed, the new index of the second tool now becomes 0. So, it makes sense for the second remove op to also happen at index 0 as this is where the (previously) second tool moves to after the first remove op.
This behavior probably stems from the library that is used to generate the diffs, jsonpatch.