Skip to content

Commit

Permalink
raise ArgumentError if 'at' size is wrong (#4603)
Browse files Browse the repository at this point in the history
In `Sidekiq::Client.bulk_push`, now
'at' size must be the same size as
'args' (or just be a single numeric).

Fixes #4601
  • Loading branch information
BuonOmo committed Jun 18, 2020
1 parent 4338695 commit 50b9e67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/sidekiq/client.rb
Expand Up @@ -96,6 +96,7 @@ def push_bulk(items)

at = items.delete("at")
raise ArgumentError, "Job 'at' must be a Numeric or an Array of Numeric timestamps" if at && (Array(at).empty? || !Array(at).all?(Numeric))
raise ArgumentError, "Job 'at' Array must have same size as 'args' Array" if at.is_a?(Array) && at.size != args.size

normed = normalize_item(items)
payloads = args.map.with_index { |job_args, index|
Expand Down
8 changes: 8 additions & 0 deletions test/test_client.rb
Expand Up @@ -168,6 +168,14 @@ class QueuedWorker
assert_raises ArgumentError do
Sidekiq::Client.push_bulk('class' => 'QueuedWorker', 'args' => [[1], [2]], 'at' => [Time.now.to_f, :not_a_numeric])
end

assert_raises ArgumentError do
Sidekiq::Client.push_bulk('class' => QueuedWorker, 'args' => [[1], [2]], 'at' => [Time.now.to_f])
end

assert_raises ArgumentError do
Sidekiq::Client.push_bulk('class' => QueuedWorker, 'args' => [[1]], 'at' => [Time.now.to_f, Time.now.to_f])
end
end
end
end
Expand Down

0 comments on commit 50b9e67

Please sign in to comment.