1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Fix accidental inclusion of nil 'at' attribute, fixes #4321

Also, change atomic_push to check for the 'at' key rather than the value of 'at' so this error is caught early and doesn't lead to malformed job payloads in Redis (and tests will fail).
This commit is contained in:
Mike Perham 2019-10-15 09:13:17 -07:00
parent 14a4f0f73e
commit 0b370e07b2
2 changed files with 9 additions and 3 deletions

View file

@ -2,6 +2,12 @@
[Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md)
HEAD
---------
- Fix `Sidekiq::Client.push_bulk` API which was erroneously putting
invalid `at` values in the job payloads [#4321]
6.0.2
---------

View file

@ -99,8 +99,8 @@ module Sidekiq
normed = normalize_item(items)
payloads = items["args"].map.with_index { |args, index|
single_at = at.is_a?(Array) ? at[index] : at
copy = normed.merge("args" => args, "jid" => SecureRandom.hex(12), "at" => single_at, "enqueued_at" => Time.now.to_f)
copy = normed.merge("args" => args, "jid" => SecureRandom.hex(12), "enqueued_at" => Time.now.to_f)
copy["at"] = (at.is_a?(Array) ? at[index] : at) if at
result = process_single(items["class"], copy)
result || nil
@ -193,7 +193,7 @@ module Sidekiq
end
def atomic_push(conn, payloads)
if payloads.first["at"]
if payloads.first.key?("at")
conn.zadd("schedule", payloads.map { |hash|
at = hash.delete("at").to_s
[at, Sidekiq.dump_json(hash)]