GAM-team / got-your-back

Got Your Back (GYB) is a command line tool for backing up your Gmail messages to your computer using Gmail's API over HTTPS.
https://github.com/GAM-team/got-your-back/wiki
Apache License 2.0
2.56k stars 203 forks source link

Unhandled exception when cleaning (invalid) date header during restore. #432

Open Leftium opened 11 months ago

Leftium commented 11 months ago

Full steps to reproduce the issue:

  1. Backup email with (invalid?) date header (Date: 2023-07-26 18:53:25.162982)
  2. Restore email using --cleanup.

Expected outcome: GYB gracefully handles invalid date header, either:

Actual outcome: GYB exits with unhandled exception:

Traceback (most recent call last):
  File "gyb.py", line 2767, in <module>
  File "gyb.py", line 2239, in main
  File "gyb.py", line 1928, in message_hygiene
  File "email\utils.py", line 200, in parsedate_to_datetime
ValueError: Invalid date value or format "2023-07-26 18:53:25.162982"
[26812] Failed to execute script 'gyb' due to unhandled exception!

Work-around: modify date header in offending .eml file to Date: Wed, 26 Jul 2023 18:53:25 +0900

Notes: the offending email is successfully restored if --cleanup is not used.

Leftium commented 11 months ago

I modified my gyb.py to gracefully skip messages that throw exceptions while cleaning.