Nobody Left to Fly Christmas — Python Bug Hunt
Modelled on American Airlines, November 2017. A glitch in the airline's pilot scheduling system let pilots drop trips over the December holiday period, and…
- Language: Python
- Layer: Backend
- Difficulty: Easy
- Concepts: Validation, State, Time
- Modelled on: American Airlines · 2017
- Visible tests: a drop from an overstaffed trip is approved; a drop that would leave the trip short is denied
- Reward: 50 XP for a complete fix
Briefing
Modelled on American Airlines, November 2017. A glitch in the airline's pilot scheduling system let pilots drop trips over the December holiday period, and thousands of flights — reportedly around 15,000 — ended up without a pilot assigned. The airline said it would pay pilots extra to pick the trips back up. The precise root cause was not published.
This reconstruction models the failure as a trip-drop request that is approved whenever the pilot is on the trip, without checking what the trip is left with.
Fix request_drop so no approval leaves a trip under its minimum crew.
Bug report
BUG-CREW-1712 · Priority: Critical · Reported by: crew scheduling
request_drop(schedule, trip_id, pilot) returns True and removes the pilot from schedule[trip_id]["assigned"] ONLY if:
- the trip exists
- the pilot is currently assigned to it
- after removal the trip still has at least rules.min_crew(trip) pilots
Otherwise it returns False and leaves the schedule unchanged.
Observed: drops on fully-staffed December trips were approved, leaving those trips with fewer pilots than they need.
Logs
[crew] drop approved trip=AA1217 pilot=P-4410 assigned=1 required=2
[crew] drop approved trip=AA1217 pilot=P-2981 assigned=0 required=2
[crew] 2017-12 open trips without crew: risingThe code as shipped
src/crew/drops.py (editable)
rules = bug_require("./rules.py")
def request_drop(schedule, trip_id, pilot):
trip = schedule.get(trip_id)
if trip is None:
return False
if pilot not in trip["assigned"]:
return False
trip["assigned"].remove(pilot)
return True
Read-only context: src/crew/rules.py.
Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More Python bug hunts.