mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Include bad job in job validation errors, fixes #4549
This commit is contained in:
parent
756d6cb38f
commit
9dc9d0803f
2 changed files with 10 additions and 5 deletions
|
@ -8,6 +8,7 @@ Unreleased
|
|||
- Web UI - Dark Mode fixes [#4543, natematykiewicz]
|
||||
- Ensure `Rack::ContentLength` is loaded as middleware for correct Web UI responses [#4541]
|
||||
- Avoid exception dumping SSL store in Redis connection logging [#4532]
|
||||
- Better error messages in Sidekiq::Client [#4549]
|
||||
|
||||
6.0.7
|
||||
---------
|
||||
|
|
|
@ -218,16 +218,20 @@ module Sidekiq
|
|||
end
|
||||
end
|
||||
|
||||
def validate(item)
|
||||
raise(ArgumentError, "Job must be a Hash with 'class' and 'args' keys: `#{item}`") unless item.is_a?(Hash) && item.key?("class") && item.key?("args")
|
||||
raise(ArgumentError, "Job args must be an Array: `#{item}`") unless item["args"].is_a?(Array)
|
||||
raise(ArgumentError, "Job class must be either a Class or String representation of the class name: `#{item}`") unless item["class"].is_a?(Class) || item["class"].is_a?(String)
|
||||
raise(ArgumentError, "Job 'at' must be a Numeric timestamp: `#{item}`") if item.key?("at") && !item["at"].is_a?(Numeric)
|
||||
raise(ArgumentError, "Job tags must be an Array: `#{item}`") if item["tags"] && !item["tags"].is_a?(Array)
|
||||
end
|
||||
|
||||
def normalize_item(item)
|
||||
# 6.0.0 push_bulk bug, #4321
|
||||
# TODO Remove after a while...
|
||||
item.delete("at") if item.key?("at") && item["at"].nil?
|
||||
|
||||
raise(ArgumentError, "Job must be a Hash with 'class' and 'args' keys: { 'class' => SomeWorker, 'args' => ['bob', 1, :foo => 'bar'] }") unless item.is_a?(Hash) && item.key?("class") && item.key?("args")
|
||||
raise(ArgumentError, "Job args must be an Array") unless item["args"].is_a?(Array)
|
||||
raise(ArgumentError, "Job class must be either a Class or String representation of the class name") unless item["class"].is_a?(Class) || item["class"].is_a?(String)
|
||||
raise(ArgumentError, "Job 'at' must be a Numeric timestamp") if item.key?("at") && !item["at"].is_a?(Numeric)
|
||||
raise(ArgumentError, "Job tags must be an Array") if item["tags"] && !item["tags"].is_a?(Array)
|
||||
validate(item)
|
||||
# raise(ArgumentError, "Arguments must be native JSON types, see https://github.com/mperham/sidekiq/wiki/Best-Practices") unless JSON.load(JSON.dump(item['args'])) == item['args']
|
||||
|
||||
# merge in the default sidekiq_options for the item's class and/or wrapped element
|
||||
|
|
Loading…
Add table
Reference in a new issue