Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Workers fail with ruby 2.0 keyword arguments in the perform method #1356

jeremyhaile opened this Issue · 10 comments

8 participants


My worker has a perform method that uses ruby 2.0 keyword arguments:

def perform(user_id: nil, send_notification: false)

This is then called with:

MyWorker.perform_async(user_id: current_user._id, send_notification: true)

Sidekiq shows the following options in the web console: (which is correct)

{"user_id"=>"4f2ab6349d285906d800000a", "send_notification"=>true}

However, the job fails with the following error:

WARN: wrong number of arguments (1 for 0)
WARN:my_worker.rb:3:in `perform'
sidekiq-2.16.1/lib/sidekiq/processor.rb:48:in `block (3 levels) in process'

I've played around with adding an initial argument and also keyword arguments. But that then fails with the same error, but just (2 for 1)

Basically it seems that the Sidekiq introspection code doesn't see the keyword argument at all and fails.


Sidekiq does not support symbols, which keyword args depend on AFAIK. This is because method args must be native JSON types.

@mperham mperham closed this

Any plan to support this? If not possible, could it be added to this page?

Just spent some time trying to google around "sidekiq named parameters" and had a hard time finding this issue!



Perfect, will do


:frowing: can't #perform detect keyword args and convert before pushing on the job queue? Keyword args are so nice. Have any experiments been done on this?


To my knowledge, the most you can get is Method#parameters:

>> def foo(a, b=1, c: 2, d:, **z); end
=> :foo
>> method(:foo).parameters
=> [[:req, :a], [:opt, :b], [:keyreq, :d], [:key, :c], [:keyrest, :z]]

No conversion could happen before putting the job on the queue, though, because that's when serialization will convert it to JSON. You'd have to convert just before calling perform. (sidekiq-symbols is a gem that enables this functionality for a worker.)



This issue shouldn't be closed (or at the very least, sidekiq should return a more useful error message stating that keyword arguments are not supported when it detects them).



@camallen camallen referenced this issue from a commit in camallen/Panoptes
@camallen camallen remove keywork syntax from sidekiq workers
sidekiq doesn't support workers with keyword args, mperham/sidekiq#1356
@camallen camallen referenced this issue in zooniverse/Panoptes

remove keywork syntax from sidekiq workers #749

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.