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

Valid JSON Patch not getting applied at Root #142

Closed
delaneyj opened this issue May 16, 2021 · 0 comments
Closed

Valid JSON Patch not getting applied at Root #142

delaneyj opened this issue May 16, 2021 · 0 comments

Comments

@delaneyj
Copy link

Totally could be something I'm missing but I think I'm reading the spec right and check my patches via this online validator with...

Patch

[
  {
    "op": "test",
    "path": "",
    "value": {
      "id": "00000000-0000-0000-0000-000000000000",
      "parentID": "00000000-0000-0000-0000-000000000000"
    }
  },
  {
    "op": "replace",
    "path": "",
    "value": {
      "id": "759981e8-ec68-4639-a83e-513225914ecb",
      "originalID": "bar",
      "parentID": "00000000-0000-0000-0000-000000000000"
    }
  }
]

Data

{
	"id": "00000000-0000-0000-0000-000000000000",
	"parentID": "00000000-0000-0000-0000-000000000000"
}

Patch results: SUCCESS

{
  "id" : "759981e8-ec68-4639-a83e-513225914ecb",
  "originalID" : "bar",
  "parentID" : "00000000-0000-0000-0000-000000000000"
}

It appears to be occurring at patch.go line 553. Per the spec pg 4

The following JSON strings evaluate to the accompanying values:

""           // the whole document

In the codebase you don't appear to handle empty string at the root of the json object. Came up from trying to use the revertible patches generated from https://github.com/wI2L/jsondiff output.

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

1 participant