Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaxRetry with {} Queue Option Argument throwing Nil Error #21

Closed
anuonifade opened this issue Nov 8, 2024 · 5 comments
Closed

MaxRetry with {} Queue Option Argument throwing Nil Error #21

anuonifade opened this issue Nov 8, 2024 · 5 comments
Milestone

Comments

@anuonifade
Copy link
Contributor

anuonifade commented Nov 8, 2024

When Using a MaxRetry handler option for Queues and Queue Option argument is an empty hash, it throws an error.

name = "sample-max-retry"
opts[:queue_options] = {:durable=>true, :auto_delete=>false, :exclusive=>false, :arguments=>{}}
Sneakers::Handlers::Maxretry.configure_queue(
  name,
  opts
)

The line

opt_args = opts[:queue_options][:arguments] ? opts[:queue_options][:arguments].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} : {}
will throw an error.

opts[:queue_options][:arguments] ? will return true and trying to inject and empty hash will raise an error.

Changing the line

opt_args = opts[:queue_options][:arguments] ? opts[:queue_options][:arguments].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} : {}

To

opt_args = opts[:queue_options][:arguments].blank? ?  {} :  opts[:queue_options][:arguments].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}

Should fix the issue.

@michaelklishin
Copy link
Member

michaelklishin commented Nov 8, 2024

Feel free to submit a PR. Thank you.

@michaelklishin
Copy link
Member

opt_args = opts[:queue_options][:arguments].blank? ?  {} :  opts[:queue_options][:arguments].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}

should probably be

opt_args = if opts[:queue_options][:arguments].blank?
             {}
           else
             opts[:queue_options][:arguments].transform_keys(&:to_sym)
           end

@anuonifade
Copy link
Contributor Author

anuonifade commented Nov 8, 2024

Yeah, that looks ruby like. It is also important to note that transform_keys was introduced in ruby 2.5 so any lower version of ruby might not work

@michaelklishin
Copy link
Member

@anuonifade Bunny and Kicks require 2.5 and arguably should require 2.7. Should have done it a couple of years ago, in fact.

@michaelklishin michaelklishin added this to the 3.1.2 milestone Nov 8, 2024
@michaelklishin
Copy link
Member

Addressed in #22 by @anuonifade and @texpert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants