Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add special case to time_str_to_utc to handle invalid tz names #3922

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sam-w
Copy link
Contributor

@sam-w sam-w commented Feb 6, 2025

Description

See #3921

tl;dr: malformed date strings are being returned from the Gmail API and being passed to the time_str_to_utc function here:

updated_at_datetime = time_str_to_utc(updated_at)

This is the least obtrusive solution I could come up with:

  • if a datestring doesn't parse, see if it contains an offset followed by something in parens (+1234 (SOMETHING))
  • if the thing in parens is not a valid tz name, remove it parse the date with just the offset

Another option would be to use fuzzy parsing (i.e. dt = parse(datetime_str, fuzzy=True)) but that risks causing surprising behaviour elsewhere, given how widely this util is used.

How Has This Been Tested?

Added unit tests.

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

Copy link

vercel bot commented Feb 6, 2025

@sam-w is attempting to deploy a commit to the Danswer Team on Vercel.

A member of the Team first needs to authorize it.

@sam-w sam-w force-pushed the bugfix/gmail-date-parse branch from 2759cb9 to b0740fb Compare February 6, 2025 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant