Say Ela opens the fast checkout flag to fix a typo in its description. The form loads a 10% rollout. While she’s editing, Sami raises it to 25% from another tab.
Ela clicks Save. She touched only the description, but the form sends the whole flag, including the old 10%. If the API accepts that request as-is, it puts the rollout right back where it started. Ela sees her typo fixed. Sami has no reason to think his change disappeared.
If I’m reviewing that save flow, I want to see what happens when the form has been open long enough for someone else to make a change. Can Ela keep her edit without undoing Sami’s?
Attach the version to the edit
The console reads GET /flags/fast-checkout. The API returns a representation and an ETag:
HTTP/1.1 200 OK
Content-Type: application/json
ETag: "flag-7"
{"description":"Enable fast checkout","rollout":10}
When Ela saves, the console sends the tag from that original read. It keeps the quotes and treats the value as opaque. The numbers in these example tags are for readers; the client never increments them.
PUT /flags/fast-checkout HTTP/1.1
Host: flags.example
Content-Type: application/json
If-Match: "flag-7"
{"description":"Enable fast checkout for eligible carts","rollout":10}
By then, Sami’s edit has changed the representation and its tag to "flag-8". If-Match requires a strong comparison, so a weak tag such as W/"flag-7" cannot satisfy the condition. For this stale write, the server returns 412 Precondition Failed and leaves the rollout at 25%. If the API requires conditional writes, it can return 428 Precondition Required when the client omits the header. Give those cases different handling: a stale version needs reconciliation; a missing precondition points to a client or integration bug. RFC 9110: If-Match, RFC 6585: 428
Enforce the comparison where the write happens. If the server checks the version, releases the lock, then writes later, another update can slip between those steps. In a database backed service, use a transactional or atomic conditional update. For example, an update against a known row can include its expected revision in the WHERE clause and advance the revision in the same statement. Handle deletion and access checks according to your API contract. A mock can prove how the client responds to a conflict; test the real database path separately to verify that two writers using the same revision cannot both win.
Keep the draft on a 412
The client needs three values: the original record, the unsaved draft, and the latest record. Keep the original snapshot when the editor loads. On a 412, preserve the draft and fetch the current record for comparison. If that fetch fails, keep the draft and offer to retry the refresh. There is no reviewed version to save against yet.
| Field | Original | Ela’s draft | Latest from server |
|---|---|---|---|
| Rollout | 10% | 10% | 25% |
| Description | Enable fast checkout | Enable fast checkout for eligible carts | Enable fast checkout |
Ela changed only the description. The editor can propose a combined update that keeps Sami’s 25% rollout, show the changes, and wait for Ela to confirm. If both people changed the description differently, ask her to resolve that field explicitly. If the next save encounters another 412, repeat the review against the new version.
The shortcut to avoid: fetch "flag-8" and automatically replay the original body with that tag. The precondition would now match, but the body would still say 10%. A fresh tag satisfies the version check; it cannot make an old draft safe to replay.
Reproduce it in one browser
Run the real editor and point its API base URL at a Beeceptor test endpoint. Use Beeceptor’s mock rules to match the method, path, and request headers and return controlled status codes, headers, and JSON. The test harness controls which version the GET fixture serves, so the test can reproduce Sami’s update without a second browser or a precisely timed click.
Start the GET rule at 10% with ETag: "flag-7" and Cache-Control: no-store. After the editor loads that response, update the GET fixture to 25% with ETag: "flag-8", leaving the form open. Use an isolated endpoint per run, or serialize runs that change the same fixture.
Configure the PUT rules for this specific test:
Match on PUT /flags/fast-checkout
|
Return |
|---|---|
If-Match matches ^"flag-7"$
|
412 |
If-Match matches ^"flag-8"$ and the body has rollout 25 and Ela’s new description |
204 |
| Other PUT requests for this path |
400 to flag an unexpected test request |
Put the specific rules above the fallback. The exact tag patterns and body checks make this a deterministic fixture for the single-tag client contract. They do not implement the full HTTP grammar or persist writes. If the editor fetches again after the successful save, switch the GET fixture to the combined representation with a new tag. For a browser calling the mock across origins, make sure your test CORS setup allows the test origin on successful and error responses, permits PUT and the If-Match and JSON Content-Type request headers in preflight, and explicitly exposes the ETag response header to JavaScript. Fetch Standard: CORS protocol
In CI, assert the sequence as well as the screen. First, verify the stale PUT carries the old tag and gets a 412. After the refresh, verify the draft description is still visible and the review shows the current 25% rollout. Check the request log: there must be no second PUT before confirmation. After confirmation, expect one PUT with "flag-8", rollout 25, and the new description. Also exercise cancel and a second conflict; neither should erase the draft or quietly submit it.
A 412 can be a good outcome. When the editor preserves the draft and gives the user a clear review step, two people can work on the same flag without losing either person’s contribution.

Top comments (0)