Skip to content
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

Replace of non existing path results in addition of that path #65

Closed
Anatolii opened this issue Feb 7, 2018 · 2 comments
Closed

Replace of non existing path results in addition of that path #65

Anatolii opened this issue Feb 7, 2018 · 2 comments
Assignees

Comments

@Anatolii
Copy link
Contributor

Anatolii commented Feb 7, 2018

Thanks for a great library!

I found this issue which is possible to reproduce in version 0.4.2

Given I have source json:
{ }
When I apply patch:
[
{
"op" : "replace",
"path" : "some-not-existing-path",
"value" : "some-value"
}
]
Then I get result:
{
"some-not-existing-path" : "some-value"
}

I would expect that implementation will throw an exception or will skip replacement of something which does not exist.

According to the RFC-6902 specification (https://tools.ietf.org/html/rfc6902#section-4.3):
The Replace operation functionally is identical to a "remove" operation for a value, followed immediately by an "add" operation at the same location with the replacement value.
For the Remove operation target location MUST exist for the operation to be successful.

@vishwakarma
Copy link
Member

Agreed as per RFC "The target location MUST exist for the operation to be successful".
I will look into the library for this bug and will fix it as soon as possible if required.

@vishwakarma vishwakarma self-assigned this Feb 7, 2018
@holograph
Copy link
Collaborator

holograph commented Feb 7, 2018 via email

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

3 participants