diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d934782f..06eba33d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ If you were using the `SpanProcessor` before, we recommend migrating over to `config.otlp` since it's a much simpler setup. +- Treat Sidekiq nil retry as true ([#2864](https://github.com/getsentry/sentry-ruby/pull/2864)) + ### Bug Fixes - Fix `MetricEvent` timestamp serialization to float ([#2862](https://github.com/getsentry/sentry-ruby/pull/2862)) diff --git a/sentry-sidekiq/lib/sentry/sidekiq/error_handler.rb b/sentry-sidekiq/lib/sentry/sidekiq/error_handler.rb index 1ff14eb99..af5b78900 100644 --- a/sentry-sidekiq/lib/sentry/sidekiq/error_handler.rb +++ b/sentry-sidekiq/lib/sentry/sidekiq/error_handler.rb @@ -61,7 +61,7 @@ def call(ex, context, sidekiq_config = nil) def retryable?(context) retry_option = context.dig(:job, "retry") # when `retry` is not specified, it's default is `true` and it means 25 retries. - retry_option == true || (retry_option.is_a?(Integer) && retry_option.positive?) + retry_option.nil? || retry_option == true || (retry_option.is_a?(Integer) && retry_option.positive?) end # @return [Integer] the number of retries allowed for the job @@ -73,7 +73,7 @@ def retry_limit(context, sidekiq_config) case limit when Integer limit - when TrueClass + when TrueClass, NilClass max_retries = if WITH_SIDEKIQ_7 # Sidekiq 7.1.5+ passes the config to the error handler, so we should use that. diff --git a/sentry-sidekiq/spec/sentry/sidekiq_spec.rb b/sentry-sidekiq/spec/sentry/sidekiq_spec.rb index cd11d3cd9..4c2cc344a 100644 --- a/sentry-sidekiq/spec/sentry/sidekiq_spec.rb +++ b/sentry-sidekiq/spec/sentry/sidekiq_spec.rb @@ -210,6 +210,24 @@ def retry_last_failed_job end end + context "when retry is nil in the job payload (e.g. raw payload pushed by AWS Lambda)" do + it "treats the job as retryable by default and does not report on first failure" do + context = { + job: { + "class" => "SadWorker", + "jid" => "abc123", + "queue" => "default", + "retry_count" => nil + } + } + + handler = Sentry::Sidekiq::ErrorHandler.new + handler.call(RuntimeError.new("I'm sad!"), context) + + expect(transport.events.count).to eq(0) + end + end + context "when retry is not specified on the worker" do before do # this is required for Sidekiq to assign default options to the worker