Commission on the Tax — JavaScript Bug Hunt
Modelled on Uber's New York City driver underpayment (acknowledged May 2017): since late 2014 Uber had been calculating its commission on NYC drivers' gross…
- Language: JavaScript
- Layer: Backend
- Difficulty: Easy
- Concepts: Money, Validation
- Modelled on: Uber · 2017
- Visible tests: a trip with no tax or fees; commission is taken from the fare, not the taxes
- Reward: 50 XP for a complete fix
Incident
- Severity: SEV-2 (priority: High (driver pay))
- Ticket: BUG-NYC-COMM
- Reported by: driver support
- Time to fix: 10 minutes, the target for an easy incident
Failing checks on the shipped build
- commission is taken from the fare, not the taxes — expected {"gross":2227,"commission":500,"taxesAndFees":227,"driverPay":1500} but got {"gross":2227,"commission":557,"taxesAndFees":227,"driverPay":1443}
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
Modelled on Uber's New York City driver underpayment (acknowledged May 2017): since late 2014 Uber had been calculating its commission on NYC drivers' gross fares, including sales tax and Black Car Fund fees, instead of on the fare after those pass-through charges. Uber said it would repay the affected drivers with interest — reported at tens of millions of dollars.
statement.js is a reconstruction of the per-trip driver statement. Taxes and fees are collected from the rider and passed on; they are not part of the fare the commission applies to.
Fix statement so the commission is taken from the fare alone.
Bug report
BUG-NYC-COMM · Priority: High (driver pay) · Reported by: driver support
statement(trip) — all amounts in integer cents — returns, in this key order:
- gross: trip.fare + trip.salesTax + trip.blackCarFund (what the rider paid)
- commission: Math.round(trip.fare * rates.COMMISSION_RATE) (the fare only — never tax or fees)
- taxesAndFees: trip.salesTax + trip.blackCarFund
- driverPay: trip.fare - commission
Example: fare 2000, tax 177, BCF 50 -> { gross: 2227, commission: 500, taxesAndFees: 227, driverPay: 1500 }
Observed: commission 557 and driver pay 1443 on that trip.
Logs
[payouts] trip=nyc-88213 fare=2000 tax=177 bcf=50 commission=557
[payouts] weekly statement NYC: commission base includes tax + BCFThe code as shipped
src/pay/statement.js (editable)
var rates = require("./rates");
// Per-trip driver statement. All amounts are integer cents.
exports.statement = function (trip) {
var gross = trip.fare + trip.salesTax + trip.blackCarFund;
var taxesAndFees = trip.salesTax + trip.blackCarFund;
var commission = Math.round(gross * rates.COMMISSION_RATE);
return {
gross: gross,
commission: commission,
taxesAndFees: taxesAndFees,
driverPay: gross - taxesAndFees - commission
};
};
Read-only context: src/pay/rates.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.