Skip to content

Bug when rail routes are returned - crashes #146

@deasmi

Description

@deasmi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions