Invalid user timezone jams up their mail

If a user’s timezone is invalid, at least one sidekiq job throws an exception rather than falling back to a reasonable default:

In this case the user’s timezone was set to "" (empty string).

We shouldn’t allow this to happen in the first place, and if it does, pick a reasonable fallback (UTC).

3 Likes

We were accounting for nil timezones in these emails but not for "" values.

There’s an issue somewhere else with this instance that has timezones for the users set to "", that said, we should make sure emails don’t fail on an invalid timezone.

Added a PR for that here: FIX: Ensure invalid timezone does not block critical emails by pmusaraj · Pull Request #26607 · discourse/discourse · GitHub

also meta:

[1] pry(main)> UserOption.where(timezone: '').count
=> 17

and (another site):

[1] pry(main)> UserOption.where(timezone: '').count
=> 6