Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
This repository was archived by the owner on Jan 16, 2026. It is now read-only.

Flights.get_results blows up if create_session gets "error" answer from SkyScanner server #24

@ditiem

Description

@ditiem

The method create_session in the Flights class does not always return a "url" (see POINT 2 below, where a callback is supposed to be called to return the Location header for a given response object), making the call to "poll_session" (see POINT 1 below) blow up. Notice create_session returns a "request library" response object if something went wrong.

PROBLEM:

Notice poll_session calls make_request straight away passing poll_url without any check:

def poll_session(self, poll_url, initial_delay=2, delay=1, tries=20,
                 errors=GRACEFUL, **params):
    ...
    for n in range(tries):
        poll_response = **self.make_request(
            poll_url,**
            headers=self._headers(),
            errors=errors, **params
        )

and in make_request there is a line that assumes the first argument, service_url, is an string:

    if 'apikey' not in service_url.lower(): <--- Boom! Object Response does not have any lower method

TRACE:

class Transport(object):
...
    def get_result(self, errors=GRACEFUL, **params):
    ...
        return self.poll_session(
            self.create_session(**params), <--- POINT 1


class Flights(Transport):
    ...
    def create_session(self, **params):
        ...
        return self.make_request(self.PRICING_SESSION_URL,
                                 method='post',
                                 headers=self._session_headers(),
                                 allow_redirects=False,
                                 callback=lambda resp: resp.headers['location'],  <---- POINT 2
                                 data=params)

POINT 2 is not executed, and instead Flights.create_session returns a response object, which becomes the poll_url argument of poll_session.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions