Skip to content

Commit 86f188e

Browse files
committed
Treat sidekiq nil retry as true
1 parent e340018 commit 86f188e

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
If you were using the `SpanProcessor` before, we recommend migrating over to `config.otlp` since it's a much simpler setup.
2424

25+
- Treat Sidekiq nil retry as true ([#2864](https://github.com/getsentry/sentry-ruby/pull/2864))
26+
2527
### Bug Fixes
2628

2729
- Fix `MetricEvent` timestamp serialization to float ([#2862](https://github.com/getsentry/sentry-ruby/pull/2862))

sentry-sidekiq/lib/sentry/sidekiq/error_handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def call(ex, context, sidekiq_config = nil)
6161
def retryable?(context)
6262
retry_option = context.dig(:job, "retry")
6363
# when `retry` is not specified, it's default is `true` and it means 25 retries.
64-
retry_option == true || (retry_option.is_a?(Integer) && retry_option.positive?)
64+
retry_option.nil? || retry_option == true || (retry_option.is_a?(Integer) && retry_option.positive?)
6565
end
6666

6767
# @return [Integer] the number of retries allowed for the job

sentry-sidekiq/spec/sentry/sidekiq_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,24 @@ def retry_last_failed_job
210210
end
211211
end
212212

213+
context "when retry is nil in the job payload (e.g. raw payload pushed by AWS Lambda)" do
214+
it "treats the job as retryable by default and does not report on first failure" do
215+
context = {
216+
job: {
217+
"class" => "SadWorker",
218+
"jid" => "abc123",
219+
"queue" => "default",
220+
"retry_count" => nil
221+
}
222+
}
223+
224+
handler = Sentry::Sidekiq::ErrorHandler.new
225+
handler.call(RuntimeError.new("I'm sad!"), context)
226+
227+
expect(transport.events.count).to eq(0)
228+
end
229+
end
230+
213231
context "when retry is not specified on the worker" do
214232
before do
215233
# this is required for Sidekiq to assign default options to the worker

0 commit comments

Comments
 (0)