Skip to content

Error applying patch created by make_patch #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
trvrm opened this issue Aug 25, 2016 · 3 comments
Closed

Error applying patch created by make_patch #54

trvrm opened this issue Aug 25, 2016 · 3 comments

Comments

@trvrm
Copy link

trvrm commented Aug 25, 2016

applying a simple patch created by diffing a list containing a dict:

        src = [{}]
        dst = [{'key': ''}]
        patch = jsonpatch.make_patch(src, dst)
        res = patch.apply(src)

causes

jsonpatch.JsonPatchConflict: can't replace non-existent object 'key'
@trvrm
Copy link
Author

trvrm commented Aug 25, 2016

The patch seems wrong:

print(patch.patch)
[{'value': '', 'path': '/0/key', 'op': 'replace'}]

Whereas if I just try to diff the inner dict:

jsonpatch.make_patch(src[0],dst[0]).patch

I get

[{'op': 'add', 'path': '/key', 'value': ''}]

Which is what I'd expect.

@trvrm
Copy link
Author

trvrm commented Aug 25, 2016

This is a regression - it doesn't happen in versions prior to a33021b

mrhadenough added a commit to mrhadenough/python-json-patch that referenced this issue Mar 8, 2017
mrhadenough added a commit to mrhadenough/python-json-patch that referenced this issue Mar 8, 2017
mrhadenough added a commit to mrhadenough/python-json-patch that referenced this issue Mar 8, 2017
@stefankoegl
Copy link
Owner

This should have been resolved by #59. I will release a new version soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants