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

RescuedExceptionInterceptor: Handle empty configuration #2428

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Fix Vernier profiler not stopping when already stopped [#2429](https://github.com/getsentry/sentry-ruby/pull/2429)
- Fix `send_default_pii` handling in rails controller spans [#2443](https://github.com/getsentry/sentry-ruby/pull/2443)
- Fixes [#2438](https://github.com/getsentry/sentry-ruby/issues/2438)
- Fix `RescuedExceptionInterceptor` to handle an empty configuration [#2428](https://github.com/getsentry/sentry-ruby/pull/2428)

## 5.21.0

Expand Down
11 changes: 10 additions & 1 deletion sentry-rails/lib/sentry/rails/rescued_exception_interceptor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@
end

def report_rescued_exceptions?
Sentry.configuration.rails.report_rescued_exceptions
# In rare edge cases, `Sentry.configuration` might be `nil` here.
# Hence, we use a safe navigation and fallback to a reasonable default
# of `true` in case the configuration couldn't be loaded.
# See https://github.com/getsentry/sentry-ruby/issues/2386
report_rescued_exceptions = Sentry.configuration&.rails&.report_rescued_exceptions
MrSerth marked this conversation as resolved.
Show resolved Hide resolved
return report_rescued_exceptions unless report_rescued_exceptions.nil?

# `true` is the default for `report_rescued_exceptions`, as specified in
# `sentry-rails/lib/sentry/rails/configuration.rb`.
true

Check warning on line 31 in sentry-rails/lib/sentry/rails/rescued_exception_interceptor.rb

View check run for this annotation

Codecov / codecov/patch

sentry-rails/lib/sentry/rails/rescued_exception_interceptor.rb#L31

Added line #L31 was not covered by tests
end
end
end
Expand Down
Loading