Senior · Design · If-Match and atomic versioned updates

Design an optimistic HTTP update with missing, weak, wildcard and multi-tag conditions, including a controlled concurrent writer and persisted-state checks.

Think through your answer before opening the explanation.

Production engineering

Reveal answer and reasoning

Design a conditional update around the complete standard precondition and the authoritative storage boundary. Specify missing, malformed, weak, wildcard and stale policies rather than treating every header string as one integer. Preserve actual persisted-state checks and a controlled interleaving when refactoring the read/write sequence. The console remains an independent decision example, while SQLite and real HTTP establish the stronger behavior.

Authorization, conflict presentation and a user's merge decision remain separate responsibilities. A412 can protect against overwrite without automatically producing the correct merged content or granting permission for another attempt.

For a concurrent editor, establish which representation version a client saw and how the server maintains its validator. Use an atomic database unit to evaluate the entire accepted condition and perform the mutation, with no unrelated awaited work inside that unit. Return a distinguishable precondition failure and let the application choose an explicit refresh or merge flow. Test that a valid multi-tag list still works when another writer advances state before this unit begins.

Keep identity trust and request authorization outside the claim that version comparison alone supplies them.

What a strong answer covers

  • The console advances version1 to2 once, then rejects stale and weak inputs.
  • Actual missing If-Match is428; a stale or weak mismatch is412 without a write.
  • The full parsed list is evaluated after reading current state inside the same SQLite write transaction.

Common pitfall

Assuming a pre-read narrowed to one version preserves the semantics of the entire If-Match list.

Follow-up questions

  1. How can a stale pre-read reject a still-valid multi-tag condition?
  2. Which user-facing merge and authorization decisions remain after a412?

Self-review

Choose what to revisit. These marks are your own assessment and are separate from lesson completion.

Primary references

Open lesson and code ↗

← All interview questions