The Update That Redirected Your Documents Away

Medium

· Backend

Incident

SEV-1

BUG-1809

Priority: Critical (data loss) · reported by update reliability

Time to fix: 20 min

Failing checks on the shipped build

  • a folder with files is never removed

    a non-empty folder must survive: expected {"removed":false,"reason":"not-empty"} but got {"removed":true,"reason":"ok"}

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

Windows 10 · 1809

Modelled on the Windows 10 October 2018 Update (build 1809): known-folder redirection had left some users with two Documents folders. The updater deleted the original folder without checking whether it still held files, and people lost photos and documents. Microsoft pulled the update within days.

redirect.js performs the same cleanup and skips the emptiness check.

Fix cleanupOldFolder so a folder with contents is never removed.

Code map

// Removes the pre-redirect folder after a known-folder move.
exports.cleanupOldFolder = function (fs, oldPath, newPath) {
  delete fs[oldPath];
  return { removed: true, reason: "ok" };
};

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 Update That Redirected Your Documents Away — Bug Hunt

Modelled on the Windows 10 October 2018 Update (build 1809): known-folder redirection had left some users with two Documents folders.

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Migration, Data Loss
  • Modelled on: Windows 10 · 1809
  • Visible tests: an empty old folder is removed; a folder with files is never removed
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical (data loss))
  • Ticket: BUG-1809
  • Reported by: update reliability
  • Time to fix: 20 minutes, the target for a medium incident

Failing checks on the shipped build

  • a folder with files is never removed — a non-empty folder must survive: expected {"removed":false,"reason":"not-empty"} but got {"removed":true,"reason":"ok"}

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

Modelled on the Windows 10 October 2018 Update (build 1809): known-folder redirection had left some users with two Documents folders. The updater deleted the original folder without checking whether it still held files, and people lost photos and documents. Microsoft pulled the update within days.

redirect.js performs the same cleanup and skips the emptiness check.

Fix cleanupOldFolder so a folder with contents is never removed.

Bug report

BUG-1809 · Priority: Critical (data loss) · Reported by: update reliability

cleanupOldFolder(fs, oldPath, newPath) must:

  • remove oldPath only when it exists AND is empty
  • never remove it when it still contains files
  • never remove newPath under any circumstance
  • return { removed: bool, reason: "ok" | "not-empty" | "missing" | "same" }

Observed: the old folder is deleted unconditionally, taking its contents with it.

Logs

[kfr] removed C:\Users\sam\Documents (14,203 files)
[kfr] redirect target C:\OneDrive\Documents contained 0 of them

The code as shipped

src/update/redirect.js (editable)

// Removes the pre-redirect folder after a known-folder move.
exports.cleanupOldFolder = function (fs, oldPath, newPath) {
  delete fs[oldPath];
  return { removed: true, reason: "ok" };
};

Read-only context: src/update/FS.js.

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 JavaScript bug hunts.