Job exception: Holidays::InvalidRegion

AI-generated summary

A user reports a recurring Job exception: Holidays::InvalidRegion error in the Discourse calendar plugin, with over 4,000 instances. The issue stems from outdated Calendar Region preferences set by users for regions that were removed or restructured in a recent update to the holiday definitions. The error occurs every 10 minutes due to a scheduled job. A contributor explains that users with invalid region preferences (e.g., state-level regions like us_id) need to update their settings to valid top-level regions (e.g., United States). While the error doesn’t affect the site’s functionality for most users, it prevents holiday events from being generated for affected users. A fix has been proposed in a pull request here, and the topic has been moved to the bug category for further attention. one1 appreciates the guidance and confirms the issue is resolved after applying the fix. selase provides detailed steps for identifying and correcting invalid region preferences, while zogstrip shares that they resolved the same issue internally.

I’m new at Discourse troubleshooting, so I’m not sure where to start on this.

This started a month or so ago. I’m now at 4347 instances of Job exception: Holidays::InvalidRegion.

/var/www/discourse/plugins/discourse-calendar/vendor/holidays/lib/holidays/finder/context/parse_options.rb:83:in `block in validate!'
/var/www/discourse/plugins/discourse-calendar/vendor/holidays/lib/holidays/finder/context/parse_options.rb:82:in `each'
/var/www/discourse/plugins/discourse-calendar/vendor/holidays/lib/holidays/finder/context/parse_options.rb:82:in `validate!'
/var/www/discourse/plugins/discourse-calendar/vendor/holidays/lib/holidays/finder/context/parse_options.rb:41:in `parse_regions!'
/var/www/discourse/plugins/discourse-calendar/vendor/holidays/lib/holidays/finder/context/parse_options.rb:20:in `call'
/var/www/discourse/plugins/discourse-calendar/vendor/holidays/lib/holidays/finder/context/between.rb:14:in `call'
/var/www/discourse/plugins/discourse-calendar/vendor/holidays/lib/holidays.rb:49:in `between'
/var/www/discourse/plugins/discourse-calendar/app/services/discourse_calendar/holiday.rb:14:in `find_holidays_for'
/var/www/discourse/plugins/discourse-calendar/jobs/scheduled/create_holiday_events.rb:68:in `block in execute'
/var/www/discourse/plugins/discourse-calendar/jobs/scheduled/create_holiday_events.rb:66:in `each'
/var/www/discourse/plugins/discourse-calendar/jobs/scheduled/create_holiday_events.rb:66:in `execute'
/var/www/discourse/app/jobs/base.rb:318:in `block (2 levels) in perform'
rails_multisite-7.0.0/lib/rails_multisite/connection_management/null_instance.rb:49:in `with_connection'
rails_multisite-7.0.0/lib/rails_multisite/connection_management.rb:17:in `with_connection'
/var/www/discourse/app/jobs/base.rb:305:in `block in perform'
/var/www/discourse/app/jobs/base.rb:301:in `each'
/var/www/discourse/app/jobs/base.rb:301:in `perform'
/var/www/discourse/app/jobs/base.rb:381:in `perform'
mini_scheduler-0.18.0/lib/mini_scheduler/manager.rb:137:in `process_queue'
mini_scheduler-0.18.0/lib/mini_scheduler/manager.rb:77:in `worker_loop'
mini_scheduler-0.18.0/lib/mini_scheduler/manager.rb:63:in `block (2 levels) in ensure_worker_threads'

env

hostname	discourse-app
process_id	3072273
application_version	66f53ac5b9c7fdcd53868ccabac310b13ffc8910
current_db	default
current_hostname	discourse.------------.net
job	DiscourseCalendar::CreateHolidayEvents
problem_db	default
time	2:53 pm
	
opts	

We haven’t modified the discourse-calendar plugin.

Can someone start to point me in the right direction?

This is likely due to a recent update to the holiday definitions, which may have caused the generated region list to change without updating users’ existing Calendar Region preferences.

The error occurs for users who previously selected one of the now-removed regions as their Calendar Region.

You’re seeing that many instances of the exception because the scheduled job that triggers this runs every 10 minutes.

We’ll need to handle this more gracefully, by accounting for holiday definition updates that remove regions from the generated region list.

1 Like

Interesting! I can say that our user base is exceptionally international, so that may track.

Am I correct to assume that 1) there is nothing I can do about this and 2) it doesn’t really matter much? Or do I need to make a bug report?

Thanks

I’ve moved this topic to Contribute > Bug, so there’s no need to make another report.

Since we haven’t actually removed any major regions here, I suspect the issue is related to state- or territory-level region definitions similar to what you see below for the US:

The change most likely happened between these two commits

That depends on your comfort level with poking around the internals. You’ll need to:

  1. Identify users who have a Calendar Region preference set.
  2. Check which of those values are not in the current list of valid regions:
    REGIONS.rb
  3. Update those users’ region preferences to a valid top-level region. For example, a preference setting like United States (us_id) should become United States

It does if your site uses holiday calendar events. For affected users, no holiday events will be generated until their Calendar Region is fixed.

2 Likes

Thank you! I appreciate your help.

Was investigating the same issue because we had a surge in errors for our internal discourse instance, so I fixed it :wink:

https://github.com/discourse/discourse/pull/35473

3 Likes

Wonderful! Thank you.