Version 1.10 Beats Version 1.9 — JavaScript Bug Hunt
Inspired by every auto-updater that ever refused to update: comparing version strings as strings makes "1.10.0" sort before "1.9.0", so half the fleet stays…
- Language: JavaScript
- Layer: Backend
- Difficulty: Easy
- Concepts: Versioning, Parsing
- Modelled on: Auto-updaters
- Visible tests: double-digit segments compare numerically; ordinary bumps still register
- Reward: 50 XP for a complete fix
Incident
- Severity: SEV-2 (priority: High)
- Ticket: BUG-VERCMP
- Reported by: release eng
- Time to fix: 10 minutes, the target for an easy incident
Failing checks on the shipped build
- double-digit segments compare numerically — ten is greater than nine: expected a truthy value but got false
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 every auto-updater that ever refused to update: comparing version strings as strings makes "1.10.0" sort before "1.9.0", so half the fleet stays on the old release forever.
semver.js — compare numerically, segment by segment.
Bug report
BUG-VERCMP · Priority: High · Reported by: release eng
isNewer(a, b) — true iff version a is strictly newer than b:
- compare dot-separated segments numerically
- missing segments count as 0 ("2.0" == "2.0.0")
Observed: "1.10.0" is treated as OLDER than "1.9.0"; the updater loops.
Logs
[updater] latest=1.10.0 current=1.9.0 -> "already up to date"The code as shipped
src/release/semver.js (editable)
// Version comparison for the auto-updater.
exports.isNewer = function (a, b) {
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.