diff --git a/Changes.md b/Changes.md index 9f892e79..c5852a5a 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,7 @@ HEAD --------- +- Strict argument checking now runs after client-side middleware [#5246] - Fix page events with live polling [#5184] - Many under-the-hood changes to remove all usage of the term "worker" from the Sidekiq codebase and APIs. This mostly involved RDoc and local diff --git a/lib/sidekiq/client.rb b/lib/sidekiq/client.rb index 4b137548..1dced454 100644 --- a/lib/sidekiq/client.rb +++ b/lib/sidekiq/client.rb @@ -75,6 +75,7 @@ module Sidekiq normed end if payload + verify_json(payload) raw_push([payload]) payload["jid"] end @@ -110,6 +111,7 @@ module Sidekiq copy = normed.merge("args" => job_args, "jid" => SecureRandom.hex(12)) copy["at"] = (at.is_a?(Array) ? at[index] : at) if at result = middleware.invoke(copy["class"], copy, copy["queue"], @redis_pool) do + verify_json(copy) copy end result || nil diff --git a/lib/sidekiq/job_util.rb b/lib/sidekiq/job_util.rb index 3e520acc..721bade6 100644 --- a/lib/sidekiq/job_util.rb +++ b/lib/sidekiq/job_util.rb @@ -12,7 +12,9 @@ module Sidekiq 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 verify_json(item) job_class = item["wrapped"] || item["class"] if Sidekiq.options[:on_complex_arguments] == :raise msg = <<~EOM