jdholtz / auto-southwest-check-in

A Python script that automatically checks in to your Southwest flight 24 hours beforehand.
GNU General Public License v3.0
453 stars 85 forks source link

"ERROR__AIR_TRAVEL__BEFORE_CHECKIN_WINDOW" on returning flight in a round trip reservation #257

Closed chy8803 closed 5 months ago

chy8803 commented 5 months ago

Version

Auto-Southwest Check-In v7.4

Browser Version

124.0.6367.119

Description

Failed to schedule a check-in on a return flight within a round trip reservation.

To Reproduce

python3 southwest.py {Reservation#} {FirstName} {LastName} -v

Expected Behavior

Check-in can be scheduled.

Relevant logs and program output

[6/05/24 1:05:53]  ~/Documents/PBGithub/auto-southwest-check-in/ [master*] python3 southwest.py CONFIRMATION_NUMBER firstName lastName -v --debug-screenshots
2024-05-06 01:08:40 DEBUG MainProcess[log:23]: Initialized the application
2024-05-06 01:08:40 DEBUG MainProcess[main:105]: Auto-Southwest Check-In v7.4
2024-05-06 01:08:40 DEBUG MainProcess[main:66]: Called with 3 arguments
2024-05-06 01:08:40 DEBUG MainProcess[config:132]: Initializing configuration file
2024-05-06 01:08:40 DEBUG MainProcess[config:161]: Reading the configuration file
2024-05-06 01:08:40 DEBUG MainProcess[config:165]: No configuration file found. Using defaults
2024-05-06 01:08:40 DEBUG MainProcess[config:174]: Reading configuration from environment variables
2024-05-06 01:08:40 DEBUG MainProcess[main:79]: Adding reservation through CLI arguments
2024-05-06 01:08:40 DEBUG MainProcess[config:151]: Creating configurations for 1 reservations
2024-05-06 01:08:40 DEBUG MainProcess[main:90]: Monitoring 0 accounts and 1 reservations
2024-05-06 01:08:40 DEBUG Process-1[reservation_monitor:62]: Acquiring lock...
2024-05-06 01:08:40 DEBUG Process-1[reservation_monitor:64]: Lock acquired
2024-05-06 01:08:40 DEBUG Process-1[checkin_scheduler:51]: Refreshing headers for current session
2024-05-06 01:08:40 DEBUG Process-1[webdriver:71]: Taking debug screenshots
2024-05-06 01:08:40 DEBUG Process-1[webdriver:133]: Starting webdriver for current session
2024-05-06 01:08:43 DEBUG Process-1[webdriver:149]: Using browser version: 124.0.6367.119
2024-05-06 01:08:43 DEBUG Process-1[webdriver:153]: Loading Southwest Check-In page
2024-05-06 01:08:47 DEBUG Process-1[webdriver:88]: Waiting for valid headers
2024-05-06 01:08:47 DEBUG Process-1[webdriver:182]: Waiting for headers_set to be set
2024-05-06 01:08:47 DEBUG Process-1[webdriver:186]: headers_set set successfully
2024-05-06 01:08:48 DEBUG Process-1[reservation_monitor:86]: Scheduling flight check-ins for 1 reservations
2024-05-06 01:08:48 DEBUG Process-1[checkin_scheduler:78]: Retrieving reservation information
2024-05-06 01:08:51 DEBUG Process-1[utils:34]: Successfully made request after 1 attempts
2024-05-06 01:08:51 DEBUG Process-1[checkin_scheduler:91]: Successfully retrieved reservation information
2024-05-06 01:08:51 DEBUG Process-1[checkin_scheduler:58]: 2 flights found under current reservation
2024-05-06 01:08:51 DEBUG Process-1[checkin_scheduler:44]: 2 total flights were found
2024-05-06 01:08:51 DEBUG Process-1[checkin_scheduler:109]: 2 new flights found
2024-05-06 01:08:51 DEBUG Process-1[checkin_scheduler:113]: Scheduling 2 flights for check-in
2024-05-06 01:08:51 DEBUG Process-1[checkin_handler:47]: Scheduling check-in for current flight
2024-05-06 01:08:51 DEBUG Process-1[checkin_handler:47]: Scheduling check-in for current flight
2024-05-06 01:08:51 DEBUG Process-1[notification_handler:69]: Sending new flights notification
Successfully scheduled the following flights to check in for firstName lastName:
Flight from San Jose to Honolulu (Oahu) on 2024-04-30 8:00 AM PDT
Flight from Honolulu (Oahu) to San Jose on 2024-05-07 12:00 PM HST

2024-05-06 01:08:51 DEBUG Process-1[checkin_scheduler:125]: 2 flights are currently scheduled. Removing old flights
2024-05-06 01:08:51 DEBUG Process-1[checkin_scheduler:141]: Successfully removed old flights. 2 flights are now scheduled
2024-05-06 01:08:51 DEBUG Process-1[reservation_monitor:95]: Checking fares for 2 flights
2024-05-06 01:08:51 DEBUG Process-1[fare_checker:30]: Checking current price for flight
2024-05-06 01:08:51 DEBUG Process-1[fare_checker:88]: Retrieving reservation information
2024-05-06 01:08:51 DEBUG Process-1:1[checkin_handler:87]: Check-in time has passed. Going straight to check-in
2024-05-06 01:08:51 DEBUG Process-1:2[checkin_handler:95]: Sleeping until thirty minutes before check-in...
2024-05-06 01:08:51 DEBUG Process-1:1[checkin_handler:128]: Attempting to check in
Checking in to flight from 'San Jose' to 'Honolulu (Oahu)' for firstName lastName

2024-05-06 01:08:51 DEBUG Process-1:1[checkin_handler:156]: Submitting check-in with a POST request
2024-05-06 01:08:51 DEBUG Process-1:1[checkin_handler:188]: Making GET request to check in
2024-05-06 01:08:54 DEBUG Process-1[utils:34]: Successfully made request after 1 attempts
2024-05-06 01:08:54 DEBUG Process-1[fare_checker:103]: Retrieving search information for the current flight
2024-05-06 01:08:56 DEBUG Process-1[utils:34]: Successfully made request after 1 attempts
2024-05-06 01:08:56 DEBUG Process-1[fare_checker:82]: Retrieving matching flights
2024-05-06 01:09:02 DEBUG Process-1[utils:48]: Failed to make request after 8 attempts: Too Many Requests 429
2024-05-06 01:09:02 DEBUG Process-1[utils:50]: Response body: {
    "code": 429999999,

    "message": "Error.",

    "messageKey": "ERROR",

    "httpStatusCode": "BAD_REQUEST",

    "requestId": "",

    "infoList": []
   }
2024-05-06 01:09:02 ERROR Process-1[reservation_monitor:107]: Requesting error during fare check. Too Many Requests 429. Skipping...
2024-05-06 01:09:02 DEBUG Process-1[fare_checker:30]: Checking current price for flight
2024-05-06 01:09:02 DEBUG Process-1[fare_checker:88]: Retrieving reservation information
2024-05-06 01:09:05 DEBUG Process-1[utils:34]: Successfully made request after 1 attempts
2024-05-06 01:09:05 DEBUG Process-1[fare_checker:103]: Retrieving search information for the current flight
2024-05-06 01:09:08 DEBUG Process-1[utils:34]: Successfully made request after 1 attempts
2024-05-06 01:09:08 DEBUG Process-1[fare_checker:82]: Retrieving matching flights
2024-05-06 01:09:10 DEBUG Process-1[utils:34]: Successfully made request after 1 attempts
2024-05-06 01:09:10 DEBUG Process-1[fare_checker:50]: Found 14 matching flights
2024-05-06 01:09:10 DEBUG Process-1[fare_checker:37]: Flight price change found for +160 USD
2024-05-06 01:09:10 DEBUG Process-1[reservation_monitor:82]: Lock released
2024-05-06 01:09:10 DEBUG Process-1[reservation_monitor:130]: Sleeping for 86370 seconds
2024-05-06 01:09:13 DEBUG Process-1:1[utils:48]: Failed to make request after 21 attempts: Bad Request 400
2024-05-06 01:09:13 DEBUG Process-1:1[utils:50]: Response body: {"code":400308191,"message":"It is too early to check in for this trip. You can check in 24 hours before departure. Come back on May 6, 2024 when it is 12:00PM in Honolulu (Oahu)","messageKey":"ERROR__AIR_TRAVEL__BEFORE_CHECKIN_WINDOW","header":null,"httpStatusCode":"BAD_REQUEST","requestId":"no-exp-id:0.3e683717.1714993751.272d9332:mweb","infoList":[]}
2024-05-06 01:09:13 DEBUG Process-1:1[checkin_handler:137]: Failed to check in. Error: Bad Request 400. Exiting
2024-05-06 01:09:13 DEBUG Process-1:1[notification_handler:112]: Sending failed check-in notification...
Failed to check in to flight CONFIRMATION_NUMBER for firstName lastName. Reason: Bad Request 400.
Check in at this url: https://mobile.southwest.com/check-in

Additional context

"messageKey":"ERROR__AIR_TRAVEL__BEFORE_CHECKIN_WINDOW" Seems it is using the departure flight date as the check-in date for the returning flight check-in date?

jdholtz commented 5 months ago

Thanks for reporting this issue. There is a check to see if the flight is departed before attempting to check in (and skips it if it has departed). It uses the departure status of the flight though, not the time and perhaps Southwest has changed the status keyword for departed flights.

Could you add the line print(flight_info["departureStatus"]) on line 63 of lib/checkin_scheduler.py to see what the departure status for the two flights are? If not, I have access to a flight departing later today so I can use that. (Edit: The departed flight is actually reporting the status the script expects once departed, so I'm interested to see what yours says)

Some more details if you or others are interested: Because Southwest uses the same reservation (conf number, name), Southwest thinks you're trying to check in to the returning flight, but the script thinks it is the departing flight (hence the Too early to check in message).

chy8803 commented 5 months ago
2024-05-06 09:19:32 DEBUG Process-2[checkin_scheduler:58]: 2 flights found under current reservation
None
None
2024-05-06 09:19:32 DEBUG Process-2[checkin_scheduler:44]: 2 total flights were found
2024-05-06 09:19:32 DEBUG Process-2[checkin_scheduler:110]: 2 new flights found
2024-05-06 09:19:32 DEBUG Process-2[checkin_scheduler:114]: Scheduling 2 flights for check-in
2024-05-06 09:19:32 DEBUG Process-2[checkin_handler:47]: Scheduling check-in for current flight
2024-05-06 09:19:32 DEBUG Process-2[checkin_handler:47]: Scheduling check-in for current flight
2024-05-06 09:19:32 DEBUG Process-2[notification_handler:69]: Sending new flights notification
Successfully scheduled the following flights to check in for FIRST LAST:
Flight from San Jose to Honolulu (Oahu) on 2024-04-30 8:00 AM PDT
Flight from Honolulu (Oahu) to San Jose on 2024-05-07 12:00 PM HST

It returned None and None

jdholtz commented 5 months ago

I have a fix for this in the departed-flights branch. Could you do git pull && git checkout departed-flights and then run the script again to see if the issue persists? If you aren't using the develop branch, you will need to run pip install -r requirements.txt as there was a new dependency added recently.

I'm not sure why the departure status of the old flight is None. Perhaps its because its a week old. I have a long flight I can access so I will look back in a week to see if I get the same status, which will confirm the hypothesis that flights on the same reservation don't have a departure status after a long period of time.

I changed the check to not rely on the departureStatus returned by Southwest but instead see if the flight time is in the past.

chy8803 commented 5 months ago

I commended on the commit and seems like i got some package import error. I fixed it by changing from datetime import UTC as datetime_utc line 4 and return datetime.now(datetime_utc) line 79 to

return datetime.now(timezone.utc)

My check-in time is passed already so I won't be able to verify that tho, but I will also keep an eye on it. Thanks.

jdholtz commented 5 months ago

Thank you, will fix that (the original only works for Python 3.11+).

My check-in time is passed already so I won't be able to verify that tho, but I will also keep an eye on it. Thanks.

No worries. I have a flight in a similar situation to yours now so the fix I have is tested on a real situation and is probably more robust. I'll merge the fix and close this issue, but if you still receive any issues with this in the future, I can reopen it.

jdholtz commented 5 months ago

I have a long flight I can access so I will look back in a week to see if I get the same status, which will confirm the hypothesis that flights on the same reservation don't have a departure status after a long period of time.

To follow up, the flight departure status becomes None after a few days (probably a recent change by Southwest).

kim-nguyenkhn commented 5 months ago

I have a fix for this in the departed-flights branch. Could you do git pull && git checkout departed-flights and then run the script again to see if the issue persists? If you aren't using the develop branch, you will need to run pip install -r requirements.txt as there was a new dependency added recently.

I'm not sure why the departure status of the old flight is None. Perhaps its because its a week old. I have a long flight I can access so I will look back in a week to see if I get the same status, which will confirm the hypothesis that flights on the same reservation don't have a departure status after a long period of time.

I changed the check to not rely on the departureStatus returned by Southwest but instead see if the flight time is in the past.

Thanks for this, I was able to successfully check in for a returning flight on my round trip reservation using develop branch 👍