Skip to content

Valid JSON Patch not getting applied at Root #142

@delaneyj

Description

@delaneyj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions