1. The problem
In one sentence
Two clients change the same thing from the same old version, and the server lets the second one silently overwrite the first.
A story
Ana and Ben both open the same record. It says "initial", version 1. Ana saves "alice". Ben, who still has the old page open, saves "bob". The spec says an update must carry the version it was made from (an If-Match header), and that a stale one is refused with 412. The server ignores the header. Both saves answer 200. Ana’s change is gone, and nobody was told.
Why it hurts
Every single answer looks right: valid status, valid body, valid headers. The damage is in the sequence, so no check of one response can see it.
- For developers: the bug is in the write path (the version check is missing or not atomic), and it only appears under concurrent use, so it passes in single-user tests.
- For managers: silent data loss. Customers lose edits without an error, support cannot reproduce it, and the loss is found by users, late.
- For DevOps: this needs a scenario with assertions, not just a
conformrun. Put it in the pipeline against a test server, as its own step, and fail on exit code1. It writes data, so give it its own data set or reset it first.
Example
The spec offers a version tag (the ETag header) on reads and expects it back in If-Match on writes. The correct sequence is:
- Ana and Ben both read the record and get the same
ETag. - Ana writes
"alice"with thatETag. Answer:200. - Ben writes
"bob"with the same, now staleETag. Correct answer:412 Precondition Failed. - A read shows
"alice".
This server does this instead:
PUT {"value":"bob"} If-Match: <stale ETag> -> 200
GET -> {"value":"bob", ...}
Both answers are valid for the spec. The disagreement is between the spec’s rule (stale writes are refused) and the behaviour (they are accepted).
How to detect it without clrsig
- With
curl: read the record and keep theETag; write once with it; write again with the sameETag. A correct server refuses the second write. - In a review, ask: “where in the code is the version compared, and is the compare and the write one atomic step?”
How to fix it
There are two usual causes:
- The code is wrong (more likely). The server does not read
If-Match, or reads it and then writes without checking. Compare the version inside the same transaction as the write, and answer412on a mismatch (or409, if that is your documented rule). - The spec is wrong or silent. The spec never says that stale writes are refused. Then the server may be doing what it was told. Add the rule to the spec (the
If-Matchheader and the412response), then fix the code.
To tell which: look at the operation in the spec. If it declares If-Match and 412, the code is wrong. Never remove the assertion to make the run pass.
Related problems
AC-042 A repeated write creates duplicates, AC-044 A write times out, yet it was done, AC-040 A business rule is broken though every response looks fine. Failure-catalog demo: FM-027-01. See also the site’s Concurrent Update and Lost-Update Failures.
Words used on this page are explained once in the glossary.
2. How clrsig helps
Check
No built-in check: checkIds is empty and the state is not caught. Each answer here is valid, so the response checks pass. clrsig sees the problem when you write the correct behaviour as assertions in a scenario: a step fails exactly where the server is wrong.
Command
First, what a single-request check says. --paths limits the run to this one operation:
clrsig conform specs/conform-fail.yaml \
-b http://localhost:8080/conform-fail \
--env clrsig/environments/conform-fail.yaml \
--paths /lost-update
Output from clrsig v0.21.0, recorded on 2026-11-30. The lines for the 74 skipped operations are left out by grep -v '^ SKIP'; no line is edited.
conform-fail API 1.0.0
Base URL: http://localhost:8080/conform-fail
Limited by --paths /lost-update
PASS GET /lost-update 200 15ms
PASS PUT /lost-update 200 3ms
PASSED 76 operations · 2 passed · 0 failed · 74 skipped 21ms
Both pass. That is the point: no single response is wrong.
Now the scenario that states the correct behaviour. Save it as lost-update.yaml:
schemaVersion: "1"
title: lost update
steps:
- label: reset
request: { method: POST, url: "{{baseUrl}}/__admin/reset" }
assertions:
- { type: status, operator: eq, expected: 204 }
failPolicy: stop
- label: read value and ETag
request: { method: GET, url: "{{baseUrl}}/lost-update" }
assertions:
- { type: status, operator: eq, expected: 200 }
extractions:
- { name: etagA, source: header, path: ETag }
failPolicy: stop
- label: first writer
request:
method: PUT
url: "{{baseUrl}}/lost-update"
headers: [{ name: If-Match, value: "{{etagA}}" }]
body: { type: json, content: '{"value":"alice"}' }
assertions:
- { type: status, operator: eq, expected: 200 }
failPolicy: stop
- label: stale writer is refused
request:
method: PUT
url: "{{baseUrl}}/lost-update"
headers: [{ name: If-Match, value: "{{etagA}}" }]
body: { type: json, content: '{"value":"bob"}' }
assertions:
- { type: status, operator: eq, expected: 412 }
failPolicy: continue
- label: first writer's value survives
request: { method: GET, url: "{{baseUrl}}/lost-update" }
assertions:
- { type: jsonpath, path: "$.value", operator: eq, expected: "alice" }
failPolicy: continue
Safety. This scenario sends
PUTandPOST. Run it against a test server, never production.clrsig conformsendsPOST,PUTandDELETErequests built from the spec: start with--read-only, and take secrets from the environment (${NAME}), never from files in the repository.
Run it:
clrsig run lost-update.yaml \
--env clrsig/environments/conform-fail.yaml \
--spec specs/conform-fail.yaml
Exit code: 0 all steps pass, 1 a step failed, 2 the scenario or the setup is broken. Here it is 1.
What you see
Output from clrsig v0.21.0, recorded on 2026-11-30:
Scenario: lost update
PASS reset 204 16ms
✓ status eq 204
PASS read value and ETag 200 2ms
✓ status eq 200
→ etagA = "\"6b86b273ff34\""
PASS first writer 200 2ms
✓ status eq 200
FAIL stale writer is refused 200 2ms
✗ status eq 412: expected "412"; got "200"
FAIL first writer's value survives 200 1ms
✗ jsonpath $.value eq alice: expected "alice"; got "bob"
Spec: 1 of 5 responses were not compared with the spec (no matching operation in the spec: 1)
FAILED 3 passed, 2 failed, 0 skipped (3/5 assertions passed) 32ms
How to read it: the step named “stale writer is refused” failed, so the server accepted a stale write. The next step shows the result: "bob" replaced "alice". The Spec: line says the reset call is not in the spec, so it was not compared; that is expected here.
Where to look
- Desktop app: open the scenario and run it; each step shows its assertions and the scenario result page lists the failed ones. Check Conformance does not show this problem, for the reason above.
- Reports: with
--format jsonorjunitonclrsig run, the failed assertions appear as failed steps. There is nocheckId, because no built-in check is involved. - GitHub Action: use
command: runwith thescenario,envandspecinputs;specreplaces the scenario’sspecFile. Older releases of the Action ignoredspecwithrun; if you use one, addspecFile: specs/conform-fail.yamlto the scenario instead (the path is relative to the scenario file) (setup and upgrading).
How clrsig helps you fix it
It tells you which step failed and the value it got ("bob" instead of "alice"), so you know the stale write was accepted and by how much. It does not know why. The “why” and the “fix” lines belong to the response checks; for a scenario you read them from section 1 above.
Limits
- clrsig does not find this by itself: you write the sequence and the correct answers. It tests one order of two clients, which is the easy case. A real race, where two writes arrive at the same moment, is not reproduced by a sequential scenario.
- A green run means nothing is wrong in what was checked. It says nothing about other records or other operations.
More ways
Nothing yet.
3. Video brief for Google NotebookLM
VIDEO BRIEF — AC-043 · A stale update overwrites a newer one (lost update)
Length: 5 to 7 minutes. Language: English. Audience: developers, with a line each for managers and DevOps.
One idea: a server can give only valid answers and still lose data; to see it you must test a sequence of calls, not one call.
Open with this story: Ana and Ben open the same record, which says "initial". Ana saves "alice". Ben, still on the old page, saves "bob". The spec says a stale write must be refused with 412, using the If-Match header. The server ignores the header. Both saves answer 200. Ana's change is gone and nobody was told.
Say these facts, in this order:
1. Every single answer is valid: status, body and headers. So a check of one response passes.
2. The correct sequence: both read the same ETag; Ana writes with it and gets 200; Ben writes with the same, now stale, ETag and must get 412; a read still shows "alice".
3. This server answers 200 to Ben and a read shows "bob".
4. clrsig conform passes both operations. That is the lesson: use a scenario with assertions that state the correct behaviour.
5. The scenario has five steps. The step "stale writer is refused" fails (expected 412, got 200) and the last step fails (expected "alice", got "bob").
6. Two usual causes: the code is wrong (the version is not compared, or not in the same step as the write), or the spec is silent about the rule. If the spec declares If-Match and 412, the code is wrong.
7. For managers: silent data loss, found by users, hard to reproduce.
8. For DevOps: run the scenario as its own pipeline step against a test server, with its own data; fail on exit code 1.
Show on screen: the correct sequence as a list, the lost-update.yaml scenario, the conform output with two PASS lines, the scenario command (clrsig run lost-update.yaml --env clrsig/environments/conform-fail.yaml --spec specs/conform-fail.yaml) and the scenario output block, copied exactly from the card.
Name the check: none; this is not caught by a built-in check, it is caught by assertions in a scenario. Say the clrsig version: v0.21.0.
Explain these words once: ETag (a tag the server gives for the current version of a thing); If-Match (a request header that says: only write if the tag still matches); 412 (the answer status for a failed precondition); scenario (a script of steps with your own checks, called assertions); exit code (0 clean, 1 a finding, 2 setup or spec broken).
Say what clrsig does not see here: it does not find this by itself; you write the sequence. A sequential scenario tests one order of two clients; a true race with simultaneous writes is not reproduced. A green run means nothing is wrong in what was checked.
Safety line (if a write is shown): Run this against a test server, never production. clrsig conform sends POST, PUT and DELETE requests built from the spec: start with --read-only, and take secrets from the environment (${NAME}), never from files in the repository.
Finish with three recap questions:
1. Why does clrsig conform pass here? (Each single answer is valid.)
2. Which step shows that the server accepted a stale write? (stale writer is refused: expected 412, got 200.)
3. If the spec declares If-Match and 412, which side is wrong? (The code.)
Tease the next video: AC-044 · A write times out, yet it was done.
Do not: say "contract testing" alone; say clrsig "catches everything"; invent flags, IDs or numbers; read tables aloud; use any fact that is not in the card.