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

Fix keyword argument error in Sneakers integration #1065

Merged
merged 1 commit into from
Jan 29, 2020

Conversation

BrianHawley
Copy link
Contributor

The Sneakers::ErrorReporter worker_error method context_hash parameter
is Hash data, not keyword parameters. Declare our handler accordingly.

The Sneakers::ErrorReporter worker_error method context_hash parameter
is Hash data, not keyword parameters. Declare our handler accordingly.
@BrianHawley
Copy link
Contributor Author

This fixes Ruby 2.7 keyword argument errors.

def call(exception, worker = nil, **context)
# rubocop:disable Style/OptionalArguments
def call(exception, worker = nil, context)
# Later versions add a middle argument.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate on this? I'm not a Sneakers user myself and this integration was contributed by someone else.
I can see that Sneakers actually always passes 2nd argument:
https:/jondot/sneakers/blob/7c059d1490e4dde43f98b801c38e4e0df7ac458c/lib/sneakers/error_reporter.rb#L18

Perhaps, we should just delete = nil so that the signature is:

def call(exception, worker, context)

Copy link
Contributor Author

@BrianHawley BrianHawley Jan 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't work with some versions of Sneakers. I'm not a Sneakers user myself but I tracked down the code that calls this handler and reviewed its commit history.

At one point they added a second argument in the middle, which they always pass in versions since then. For versions before then they only pass two arguments, which for this handler correspond to the first and last argument; for those versions, we would get nil for the middle argument if we make it optional here.

Good thing we don't actually use the middle argument in this handler.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that makes sense.

@kyrylo kyrylo merged commit f8a1337 into airbrake:master Jan 29, 2020
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

Successfully merging this pull request may close these issues.

2 participants