Skip to content

Commit a884cae

Browse files
authored
Fix compatibility issues with sidekiq-cron 2.2.0 (#2591)
* Update to support Sidekiq::Cron 2.2 Since Sidekiq::Cron 2.2.0, `Sidekiq::Cron::Support.constantize` is removed and `Sidekiq::Cron::Support.safe_constantize` is added. We need to check the method is available before calling it. Related PR: sidekiq-cron/sidekiq-cron#541 * Update changelog
1 parent 8108ddb commit a884cae

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Fixes [#2376](https://github.com/getsentry/sentry-ruby/issues/2376)
1212
- Fix breadcrumb serialization error message to be an object ([#2584](https://github.com/getsentry/sentry-ruby/pull/2584))
1313
- Fixes [#2478](https://github.com/getsentry/sentry-ruby/issues/2478)
14+
- Fix compatibility issues with sidekiq-cron 2.2.0 ([#2591](https://github.com/getsentry/sentry-ruby/pull/2591))
1415

1516
### Internal
1617

sentry-sidekiq/lib/sentry/sidekiq/cron/job.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,17 @@ def save
4545
# fail gracefully if can't find class
4646
klass_const =
4747
begin
48-
::Sidekiq::Cron::Support.constantize(klass.to_s)
48+
if ::Sidekiq::Cron::Support.respond_to?(:safe_constantize)
49+
::Sidekiq::Cron::Support.safe_constantize(klass.to_s)
50+
else
51+
::Sidekiq::Cron::Support.constantize(klass.to_s)
52+
end
4953
rescue NameError
5054
return true
5155
end
5256

57+
return true if klass_const.nil? # Sidekiq::Cron returns nil if class is not found
58+
5359
# only patch if not explicitly included in job by user
5460
unless klass_const.send(:ancestors).include?(Sentry::Cron::MonitorCheckIns)
5561
klass_const.send(:include, Sentry::Cron::MonitorCheckIns)

0 commit comments

Comments
 (0)