Skip to content

Commit

Permalink
Fixes backward incompatible Sidekiq change
Browse files Browse the repository at this point in the history
We are expecting a `config` argument to the Sidekiq exception handler,
but pre- version 7.1.5 that is not passed.

So we'll make the argument optional as it is currently unnused anyway

Fixes #183
  • Loading branch information
nikz committed May 29, 2024
1 parent c029c6e commit 18593c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/raygun/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module Raygun

class SidekiqReporter
def self.call(exception, context_hash, config)
def self.call(exception, context_hash = {}, config = nil)
user = affected_user(context_hash)
data = {
custom_data: {
Expand Down
11 changes: 11 additions & 0 deletions test/unit/sidekiq_failure_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ def test_failure_backend_appears_to_work
assert response && response.success?, "Expected success, got #{response.class}: #{response.inspect}"
end

# See https://github.com/MindscapeHQ/raygun4ruby/issues/183
# (This is how Sidekiq pre 7.1.5 calls error handlers: https://github.com/sidekiq/sidekiq/blob/1ba89bbb22d2fd574b11702d8b6ed63ae59e2256/lib/sidekiq/config.rb#L269)
def test_failure_backend_appears_to_work_without_config_argument
response = Raygun::SidekiqReporter.call(
StandardError.new("Oh no! Your Sidekiq has failed!"),
{ sidekick_name: "robin" }
)

assert response && response.success?, "Expected success, got #{response.class}: #{response.inspect}"
end

def test_we_are_in_sidekiqs_list_of_error_handlers
# Sidekiq 7.x stores error handlers inside a configuration object, while 6.x and below stores them directly against the Sidekiq module
error_handlers = Sidekiq.respond_to?(:error_handlers) ? Sidekiq.error_handlers : Sidekiq.default_configuration.error_handlers
Expand Down

0 comments on commit 18593c9

Please sign in to comment.