Skip to content

Commit

Permalink
Fix case where a recurring task key is empty in the config
Browse files Browse the repository at this point in the history
For example, when there's an entry for an environment other than the
current one being used and that one is empty.
  • Loading branch information
rosa committed Jan 2, 2025
1 parent eedb4fe commit df6137b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/solid_queue/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def dispatchers_options

def recurring_tasks
@recurring_tasks ||= recurring_tasks_config.map do |id, options|
RecurringTask.from_configuration(id, **options) if options.has_key?(:schedule)
RecurringTask.from_configuration(id, **options) if options&.has_key?(:schedule)
end.compact
end

Expand All @@ -153,7 +153,9 @@ def processes_config
end

def recurring_tasks_config
@recurring_tasks_config ||= config_from options[:recurring_schedule_file]
@recurring_tasks_config ||= begin
config_from options[:recurring_schedule_file]
end
end


Expand Down
4 changes: 4 additions & 0 deletions test/unit/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class ConfigurationTest < ActiveSupport::TestCase
assert configuration.valid?
assert_processes configuration, :scheduler, 0

configuration = SolidQueue::Configuration.new(recurring_schedule_file: config_file_path(:recurring_with_empty))
assert configuration.valid?
assert_processes configuration, :scheduler, 0

# No processes
configuration = SolidQueue::Configuration.new(skip_recurring: true, dispatchers: [], workers: [])
assert_not configuration.valid?
Expand Down

0 comments on commit df6137b

Please sign in to comment.