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

according to RFC6902 JSON patch, replace operation should fail if path not exist before #78

Closed
jerreli opened this issue May 23, 2019 · 3 comments

Comments

@jerreli
Copy link

jerreli commented May 23, 2019

This issue is the same as the previous issues(#18 and #40).
According to RFC6902 JSON patch, replace operation should fail if path not exist before. From issue#40, the auther may have merged updated code. But now when I compare codes in branch master or tag 4.2.0, I find that the place that should be updated is not updated. Does the author have other concerns? Expect the author to update the code as soon as possible~~

code in branch master and tag 4.2.0 in method replace:

_, ok := con.get(key)
if ok != nil {
	return fmt.Errorf("jsonpatch replace operation does not apply: doc is missing key: %s", path)
}

code may be merged in method replace:

val, ok := con.get(key)
if val == nil || ok != nil {
	return fmt.Errorf("jsonpatch replace operation does not apply: doc is missing key: %s", path)
}
@evanphx
Copy link
Owner

evanphx commented Jun 10, 2019

That code doesn't work, it will fail things that should pass today. Can you provide an example of a patch that doesn't work right?

@Loushu
Copy link

Loushu commented Sep 11, 2019

https://play.golang.org/p/gJUZb4dNy99

Expected result: failure to apply patch/panic
Actual result:
Original document: { "Metadata": { } }
Modified document: {"Metadata":{"key1":"val1"}}

@evanphx
Copy link
Owner

evanphx commented Aug 8, 2020

Closed as stale.

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