The One-Cent Book of Madness — JavaScript Bug Hunt
Inspired by the algorithmic pricing wars on marketplace sites — most famously the biology textbook priced at $23 million by two bots repricing against each…
- Language: JavaScript
- Layer: Backend
- Difficulty: Medium
- Concepts: Pricing, Feedback Loops
- Modelled on: Amazon repricers
- Visible tests: one round undercuts by a cent; long wars stop at the floors
- Reward: 50 XP for a complete fix
Incident
- Severity: SEV-2 (priority: High)
- Ticket: BUG-23M
- Reported by: marketplace integrity
- Time to fix: 20 minutes, the target for a medium incident
Failing checks on the shipped build
- long wars stop at the floors — floors must hold: expected [800,799] but got [400,399]
How to work this incident
- Read the report: write down the expected behaviour and the actual one in a sentence each.
- Reproduce it: run the visible tests and find the failing check that matches the report.
- 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.
- Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
- 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 algorithmic pricing wars on marketplace sites — most famously the biology textbook priced at $23 million by two bots repricing against each other, and the mirror-image death spirals racing to one cent.
Two sellers undercut each other by a cent per round. Without a floor, they race to zero. repricer.js has no floor.
Bug report
BUG-23M · Priority: High · Reported by: marketplace integrity
battle(priceA, priceB, floorA, floorB, rounds):
- each round: A = max(floorA, B - 1), then B = max(floorB, A - 1)
- returns [finalA, finalB]
Observed: after a weekend of rounds both sellers list at 1 cent — the floors are ignored entirely.
Logs
[reprice] round 84212: A=1 B=1 (floors: 800, 795)The code as shipped
src/market/repricer.js (editable)
// Simulates two repricing bots undercutting each other (cents).
exports.battle = function (priceA, priceB, floorA, floorB, rounds) {
var a = priceA, b = priceB;
for (var i = 0; i < rounds; i++) {
a = b - 1;
b = a - 1;
}
return [a, b];
};
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.