The Draft That Overwrote the Publish

Easy

· Backend

Incident

SEV-2

BUG-LWW

Priority: High (lost content) · reported by editors

Time to fix: 10 min

Failing checks on the shipped build

  • an older incoming record loses

    expected "published" but got "stale draft"

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

Sync engines

Inspired by the sync-conflict horror stories of every note-taking and CMS product: an old offline draft comes back online and steamrolls the article someone published an hour ago. Last-write-wins needs to compare timestamps, not arrival order.

sync.py merges an incoming record with the stored one.

Code map

# Last-write-wins merge of a stored and incoming record.

def merge(saved, incoming):
    return incoming

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

The Draft That Overwrote the Publish — Python Bug Hunt

Inspired by the sync-conflict horror stories of every note-taking and CMS product: an old offline draft comes back online and steamrolls the article someone…

  • Language: Python
  • Layer: Backend
  • Difficulty: Easy
  • Concepts: Sync, Timestamps
  • Modelled on: Sync engines
  • Visible tests: an older incoming record loses; a newer incoming record wins
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-2 (priority: High (lost content))
  • Ticket: BUG-LWW
  • Reported by: editors
  • Time to fix: 10 minutes, the target for an easy incident

Failing checks on the shipped build

  • an older incoming record loses — expected "published" but got "stale draft"

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Briefing

Inspired by the sync-conflict horror stories of every note-taking and CMS product: an old offline draft comes back online and steamrolls the article someone published an hour ago. Last-write-wins needs to compare timestamps, not arrival order.

sync.py merges an incoming record with the stored one.

Bug report

BUG-LWW · Priority: High (lost content) · Reported by: editors

merge(saved, incoming) — both have updated_at:

  • keep whichever has the NEWER updated_at
  • ties keep the SAVED (server) copy

Observed: incoming always wins — a laptop that was offline all week just replaced today's homepage with last Tuesday's.

Logs

[sync] doc 41: incoming updated_at=1699000000 overwrote saved 1699600000

The code as shipped

src/sync/sync.py (editable)

# Last-write-wins merge of a stored and incoming record.

def merge(saved, incoming):
    return incoming

Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More Python bug hunts.