Pcornel
Automation · APIs

PATCH

Cheat sheet · https://pcornel.dk/topic.php?topic=5298

Back to the Topic

Answer

Partial modification of an existing resource using a documented patch document or field-update contract.

Remember

  • PATCH ≠ idempotent automatically; semantics depend on the patch format and operation.
  • Partial update ≠ isolated change; server validation or derived fields can affect adjacent state.
  • Missing field ≠ null/delete unless the patch format defines it that way.
  • Successful PATCH ≠ merged state understood; the resulting full resource must be re-read.

First checks

  • curl -sS -X PATCH -H 'Content-Type: application/merge-patch+json' -d '{"enabled":false}' https://<api>/v1/items/<id> — partial update
  • JSON Patch vs Merge Patch — format
  • Idempotency of the patch — retry safety

Verify in this order

PATCH changes → partial update

Where it usually breaks

PATCH success proves the patch was processed according to the server contract; it does not prove adjacent fields remained correct.

Client payload/auth → HTTP transport → endpoint validation/policy → request accepted → queued/job execution → target mutation → effective state → consumer workload.

PATCH API boundary map

BoundaryHealthy evidenceSuspicious evidence
Caller / requestEnvironment/version, identity and exact request contract are attributableHidden defaults, wrong endpoint/version, leaked or mismatched credentials
Server / responseStatus, headers, structured body and request ID are interpreted togetherStatus-only handling, ignored error body, ambiguous async result or unsafe retry
State / proofWrite result is reconciled with resource read-back or acceptance testResponse success treated as final target success without verification
TroubleshootingFirst failed boundary is preserved, changed minimally and retestedBlind retries, credential rotation, replay or payload edits before evidence is captured

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5298

Confirmation

Confirm action

Continue?