You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@stefankoegl any ideas on what's going wrong here? I've narrowed down the issue about as much as I can without having to put in a bunch more time to figure out the underlying issue.
Unfortunately, I don't have anything I can suggest. I haven't been actively working on the project for quite some time now, so I'm not up-to-speed at the moment.
While looking into this issue I hit a related case in the same area that fails silently instead of raising: make_patch produces a patch that applies without any error but yields the wrong document. On jsonpatch 1.33:
The generated move from /1 (right after the add at /1) lands in the wrong place, so the applied result differs from dst with no error surfaced. It appears to come from the same move-optimization path as the crash in this issue, just showing up as a wrong document rather than an exception.
Activity
rmorshea commentedon Dec 24, 2021
It looks like swapping these two items fixes the patch:
{"op": "remove", "path": "/0/x/0"} {"op": "replace", "path": "/0/x/1/y/0", "value": "d"}So that the remove operation happens second:
{"op": "replace", "path": "/0/x/1/y/0", "value": "d"} {"op": "remove", "path": "/0/x/0"}rmorshea commentedon Dec 24, 2021
Removing this section of code (which I assume is some optimization heuristic) fixes the assertion: https://github.com/stefankoegl/python-json-patch/blob/master/jsonpatch.py#L828-L851
rmorshea commentedon Jan 4, 2022
For those who need to work around this until a patch is released, the following code will fix this issue (though probably with a hit to performance):
[-]Invalid Patch Generated[/-][+]Wrong Patch Generated[/+]rmorshea commentedon Jun 26, 2022
@stefankoegl any ideas on what's going wrong here? I've narrowed down the issue about as much as I can without having to put in a bunch more time to figure out the underlying issue.
rmorshea commentedon Aug 12, 2022
@stefankoegl do you have any hints you could give me on how to fix this?
It turns out that my patch hasn't complete fixed this bug and I'm in desperate need of a solution.
stefankoegl commentedon Aug 12, 2022
Unfortunately, I don't have anything I can suggest. I haven't been actively working on the project for quite some time now, so I'm not up-to-speed at the moment.
rmorshea commentedon Aug 13, 2022
Turns out my hacked fix still works. The new error I was experiencing was caused by something else.
ckarnell commentedon Sep 5, 2026
While looking into this issue I hit a related case in the same area that fails silently instead of raising:
make_patchproduces a patch that applies without any error but yields the wrong document. On jsonpatch 1.33:The generated
movefrom/1(right after theaddat/1) lands in the wrong place, so the applied result differs fromdstwith no error surfaced. It appears to come from the same move-optimization path as the crash in this issue, just showing up as a wrong document rather than an exception.Add property-based tests using Hypothesis (#194)
Add property-based tests using Hypothesis