Skip to content

Micropub Update Parsing Uncertainties

meta micropub indieweb

I am creating a new Micropub endpoint for my website and I read the specification. However, while testing the update action, something unexpected happened. The specification is not quite clear to whether we should deeply-traverse the update and update field by field, or solely replace the top-level keys.

Take into account the following post (taken from the specification):

{
  "type": ["h-entry"],
  "properties": {
    "summary": [
      "Weighed 70.64 kg"
    ],
    "weight": [
      {
        "type": ["h-measure"],
        "properties": {
          "num": ["70.64"],
          "unit": ["kg"]
        }
      }
    ]
  }
}

What happens with the following update request?

{
  "action": "update",
  "url": "https://example.com/weight",
  "replace": {
    "weight": [
      {
        "properties": {
          "unit": ["lbs"]
        }
      }
    ]
  }
}

Should the Micropub endpoint recursively traverse the fields and check if they exist and if so, update it? Or should it simply replace the top level weight field?

I am asking this because I was testing with a checkin locally, and I used OwnYourSwarm which provides a lot of detailed fields. Then, I used micropublish to update that post, and most of the fields of the checkin were gone because I was simply replacing the top-level fields.

Is anyone aware of what should happen?