python-json-patch icon indicating copy to clipboard operation
python-json-patch copied to clipboard

multiple modifications to an array fails

Open jcable opened this issue 2 years ago • 0 comments

Traceback (most recent call last):
  File ".../lib/python3.11/site-packages/jsonpointer.py", line 281, in walk
    return doc[part]
           ~~~^^^^^^
IndexError: list index out of range

This are the relevant fields from the patch:

[
    {
        "op": "remove",
        "path": "/ownerships/0"
    },
    {
        "op": "remove",
        "path": "/ownerships/5/current"
    },
    {
        "op": "add",
        "path": "/ownerships/0",
        "value": {
            "share": 64,
            "start": 2023,
            "current": true
        }
    },
    {
        "op": "add",
        "path": "/ownerships/5/end",
        "value": 2023
    }
]

The unmodified document has 6 entries in the array.

Perhaps it's processing the changes in order, so that the first change modifies the array deleting item 0 and then item 5 is not present when it gets to the next change.

jcable avatar Aug 17 '23 07:08 jcable