The Null Price Latte

Easy

· Backend

Incident

SEV-2

BUG-FREE-LATTE

Priority: High · reported by store ops

Time to fix: 10 min

Failing checks on the shipped build

  • unknown items throw loudly

    unknown sku must not be free: expected an error to be thrown

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

Starbucks POS

Inspired by the point-of-sale glitches that let customers check out carts full of items with missing prices — for free. When the menu doesn't know an item, NaN walks straight through the math and the register renders it as $0.00.

register.js must refuse instead.

Code map

// Sums a cart against the price menu (cents).
exports.total = function (items, menu) {
  var sum = 0;
  for (var i = 0; i < items.length; i++) {
    sum += menu[items[i].sku] * items[i].qty;
  }
  return sum;
};

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 Null Price Latte — JavaScript Bug Hunt

Inspired by the point-of-sale glitches that let customers check out carts full of items with missing prices — for free.

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Easy
  • Concepts: Null Safety, Pricing
  • Modelled on: Starbucks POS
  • Visible tests: known items sum correctly; unknown items throw loudly
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-2 (priority: High)
  • Ticket: BUG-FREE-LATTE
  • Reported by: store ops
  • Time to fix: 10 minutes, the target for an easy incident

Failing checks on the shipped build

  • unknown items throw loudly — unknown sku must not be free: expected an error to be thrown

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 point-of-sale glitches that let customers check out carts full of items with missing prices — for free. When the menu doesn't know an item, NaN walks straight through the math and the register renders it as $0.00.

register.js must refuse instead.

Bug report

BUG-FREE-LATTE · Priority: High · Reported by: store ops

total(items, menu) — items are { sku, qty }:

  • unknown sku -> throw "Unknown item: <sku>"
  • otherwise sum price * qty in cents

Observed: unknown skus produce NaN, the UI prints $0.00, and word spreads fast.

Logs

[pos] cart=[latte, secret-item] total=NaN -> charged $0.00

The code as shipped

src/pos/register.js (editable)

// Sums a cart against the price menu (cents).
exports.total = function (items, menu) {
  var sum = 0;
  for (var i = 0; i < items.length; i++) {
    sum += menu[items[i].sku] * items[i].qty;
  }
  return sum;
};

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.