-
Notifications
You must be signed in to change notification settings - Fork 4
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
Setting a property to a undefined value results in a patch without value argument #21
Comments
As pointed in #47 the Can this issue be closed? |
My goal was to add client-side checks before sending of generated JSON Patch that would give the developer a clear information what is wrong. We know that There is patch validation functionality in JSON-Patch (Starcounter-Jack/JSON-Patch#29). PuppetJS is using it ( |
Sure. Assigning to myself. |
If an outgoing patch has I have added three new tests, but not yet pushed, as one of them fails. |
Good catch! Can you propose a solution that passes this test? |
Looks like we have to check the outgoing changes recursively, remove private properties and check values, if there is an undefined value then replace it with |
|
Actually I think we have to reconsider that to do in this case. Let's assume the following code:
What I am sure is:
What options are we left with?
Anyway, the solution would be applied to JSON-Patch not to PuppetJs. @tomalec WDYT? |
Current validation is implemented here: https://github.com/Starcounter-Jack/JSON-Patch/blob/master/src/json-patch-duplex.js#L632 And it is throwing |
I would say, that
So my suggested behavior is described here: https://github.com/Starcounter-Jack/JSON-Patch#undefineds-json-to-js-extension To sum up. For valid JSONs we will generate, and communicate via valid JSON Patches. |
Fair enough! PuppetJs in debug mode (currently ON by default) validates outgoing patches: if(this.debug) {
this.validateSequence(this.remoteObj, patches);
} in which case the error should be reported. I am glad that we both agree :)
It should not be mixed. The current check for @miyconst could you prepare a solution for this on a separate branch in https://github.com/Starcounter-Jack/JSON-Patch? Create a new issue for it, publish code on a separate branch for review. The changes should include test and update to README.md |
I meant that the issue should be created in JSON-Patch, because it is to be solved in JSON-Patch |
The Starcounter-Jack/JSON-Patch#73 issue is closed and merged, can this one also be closed? |
To wrap up... What will be the current behavior in case described in the first message of this thread? |
The patch
Won't pass validation and the |
Thanks! |
I have added some automated tests for |
lets say "test" is undefined and "MyData" is a JSon object tat is coming from the server.
This will result in following:
The value argument of the patch is missing. (And at least SC server will complain)
The text was updated successfully, but these errors were encountered: