From 83a6981e9c39e188c842347b1b2cfacf96712d20 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Thu, 10 Oct 2024 23:40:34 +0200 Subject: [PATCH] RescuedExceptionInterceptor: Handle empty configuration Previously, it could happen that `Sentry.configuration` was `nil`. In this case, calling `rails` would produce a `NoMethodError`. We fix this issue by using safe navigation. Furthermore, this commit ensures we use a reasonable default in case the configuration couldn't be loaded. Since the config `report_rescued_exceptions` defaults to `true`, we assume this value here, too. Fixes #2386 --- .../lib/sentry/rails/rescued_exception_interceptor.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sentry-rails/lib/sentry/rails/rescued_exception_interceptor.rb b/sentry-rails/lib/sentry/rails/rescued_exception_interceptor.rb index 43cb69db1..647e94a2d 100644 --- a/sentry-rails/lib/sentry/rails/rescued_exception_interceptor.rb +++ b/sentry-rails/lib/sentry/rails/rescued_exception_interceptor.rb @@ -19,7 +19,10 @@ def call(env) end def report_rescued_exceptions? - Sentry.configuration.rails.report_rescued_exceptions + report_rescued_exceptions = Sentry.configuration&.rails&.report_rescued_exceptions + return report_rescued_exceptions unless report_rescued_exceptions.nil? + + true end end end