Skip to content

Absent collections default to empty, and an update touches only what it sends

An update is partial. What a caller does not send, it does not change, which is what lets an editor save one part of a workflow without holding the whole of it.

The rule

Normative: this is the rule
  1. On create, nodes and edges MUST default to an empty array when absent, and metadata MUST default to empty.
  2. A workflow that declares no interface declares no ports.
  3. An update is sent with PUT on the workflow_update route (API-9) and has these member-wise semantics rather than replacing the stored workflow whole.
  4. On update, a key the request omits MUST be left as stored.
  5. A key the request sends as null MUST be cleared: the workflow MUST then read as if that key had been omitted on create.
  6. name is the exception to both, and MUST be present and non-null on update as on create (STORE-2).
  7. An interface present on update MUST replace the stored interface as a whole, so a side it omits, or sends as an empty array, MUST be stored with no ports.
  8. The metadata published on read MAY differ from the metadata as stored.
  9. An implementation MAY fold envelope fields such as format and schemaVersion into it on read.

What it means

An update is sent with PUT, yet it does not replace the stored workflow whole; it works member by member. It is partial by default: a key the request does not send is left as stored, which is what lets a caller save one part of a workflow without holding the whole of it in hand. A key sent as null is the way to clear it: the workflow then reads as though the key had never been sent on create. That is the same reading JSON Merge Patch gives a partial update.

interface is replaced as a whole rather than merged: sending it at all rewrites both the inputs and the outputs it describes, even if only one of them is included. A side left out of a present interface is not "left as stored", because what is stored is being replaced; it is a side the new interface does not declare, so it has no ports.

The metadata a caller reads back is not necessarily the metadata it would get by reading the stored document directly: an implementation is free to fold housekeeping fields such as a format marker or a schema version into what it publishes on read, without those fields having been part of what was stored.

Example

Four requests to the same endpoint, each reading a different state of a key.

A create with no nodes, edges or metadata201 — stored
POST /api/flowdrop/workflows

{"id": "bare_wf", "name": "Bare"}
An update naming only the name and the nodes200 — preserved
PUT /api/flowdrop/workflows/{workflow_id}

{"name": "Partial renamed", "nodes": [ … ]}
An update whose interface is present but empty200 — cleared
PUT /api/flowdrop/workflows/{workflow_id}

{"name": "Clear", "interface": []}
An update sending metadata as null200 — cleared
PUT /api/flowdrop/workflows/{workflow_id}

{"name": "Reset", "metadata": null}

The first leaves nodes and edges as empty arrays and metadata empty — nothing was sent for them, so there is nothing to default from but empty. The second leaves the edges and metadata a prior request had set untouched, because this request never mentions them. The third is the one that reads like the second but is not: interface was sent, so both its sides are rewritten, and an empty array on either side clears it rather than leaving it as it was. The fourth clears metadata: it reads back empty, as on a create that never sent it.

Why

Recorded under OPEN-25, OPEN-26, OPEN-65.

References

Further reading

  • RFC 7396JSON Merge PatchThe same reading of a partial update: an absent member leaves the target alone, and a null member removes it.

Fixtures

Test cases whose outcome this rule decides. A case compares absent, null and empty members exactly; the fixtures README defines each operation. Where a case and the rule disagree, the rule is right.

  • An update sending an empty list stores the empty list update-workflow
    {
      "given": {
        "stored": {
          "name": "Flow",
          "nodes": [
            {
              "id": "n1"
            }
          ],
          "edges": []
        },
        "request": {
          "name": "Flow",
          "nodes": []
        }
      },
      "expect": {
        "workflow": {
          "name": "Flow",
          "nodes": [],
          "edges": []
        }
      }
    }

    fixtures/presence/store-update-empty-replaces.json

  • An update keeps what it omits and clears what it sends as null update-workflow

    edges sent as null reads as if omitted on create, where it defaults to the empty array.

    {
      "given": {
        "stored": {
          "name": "Flow",
          "nodes": [
            {
              "id": "n1"
            }
          ],
          "edges": [
            {
              "source": "n1",
              "target": "n1"
            }
          ]
        },
        "request": {
          "name": "Flow",
          "edges": null
        }
      },
      "expect": {
        "workflow": {
          "name": "Flow",
          "nodes": [
            {
              "id": "n1"
            }
          ],
          "edges": []
        }
      }
    }

    fixtures/presence/store-update-omitted-kept-null-cleared.json

Rule identifiers are permanent and are never renumbered. Each implementation publishes its own standing against these rules; this specification does not.spec 1.0 · STORE-4 · changed in spec 1.1