Bug: Search crashes when Google Flights returns non-airport codes (e.g. rail stations)
Repository: punitarani/fli
Description
Searching certain city pairs causes an unhandled AttributeError because Google Flights
includes train station codes in its results (European rail connections), which are not
present in the Airport enum.
Steps to Reproduce
fli flights LGW KRK 2027-02-28
Error
Search failed: type object 'Airport' has no attribute 'QKL'
QKL is the code for Cologne Central Station (Köln Hauptbahnhof). Google Flights
integrates European rail connections into flight results, so itineraries involving a
train leg can appear alongside pure flight options. Any search that returns such a result
currently crashes entirely, returning no flights at all.
Root Cause
SearchFlights._parse_airport() in search/flights.py does an unguarded getattr:
return getattr(Airport, airport_code)
When airport_code is a rail station code not present in the Airport enum, this raises
AttributeError and the entire search fails.
Impact
- Any routes where google suggests a rail connection will fail
Bug: Search crashes when Google Flights returns non-airport codes (e.g. rail stations)
Repository: punitarani/fli
Description
Searching certain city pairs causes an unhandled
AttributeErrorbecause Google Flightsincludes train station codes in its results (European rail connections), which are not
present in the
Airportenum.Steps to Reproduce
Error
QKL is the code for Cologne Central Station (Köln Hauptbahnhof). Google Flights
integrates European rail connections into flight results, so itineraries involving a
train leg can appear alongside pure flight options. Any search that returns such a result
currently crashes entirely, returning no flights at all.
Root Cause
SearchFlights._parse_airport() in search/flights.py does an unguarded getattr:
return getattr(Airport, airport_code)
When airport_code is a rail station code not present in the Airport enum, this raises
AttributeError and the entire search fails.
Impact