Issue Description
Setting the report_rescued_exceptions option to false doesn't seem to be effective in a Rails production environment: exceptions rescued by the ActionDispatch::ShowExceptions middleware are reported, but as per the documentation, they shouldn't.
I originally thought this bug was introduced in 7a3a86b but on closer look, I'm actually not sure this is the case. Before this commit, the CaptureExceptions middleware was wrapping the ShowExceptions middleware, so one would be tempted to think that if exceptions were swallowed by the latter, the former wouldn't report them. However, the ShowExceptions middleware sets the exception it swallows in the action_dispatch.exception header and the CaptureExceptions middleware reads this value back to report the exception (regardless of report_rescued_exceptions).
In short, I'm not sure whether this is an actual bug or whether the documentation is wrong.
Reproduction Steps
Add this spec to sentry-rails/spec/sentry/rails_spec.rb:
context "with report_rescued_exceptions = false" do
before do
make_basic_app do |config, app|
app.config.consider_all_requests_local = false
config.rails.report_rescued_exceptions = false
end
end
it "doesn't report rescued exceptions" do
get "/exception"
expect(transport.events.count).to eq(0)
end
end
Expected Behavior
The spec should pass.
Actual Behavior
The spec fails with the following message:
Failures:
1) Sentry::Rails with production config with report_rescued_exceptions = false doesn't report rescued exceptions
Failure/Error: expect(transport.events.count).to eq(0)
expected: 0
got: 1
(compared using ==)
# ./spec/sentry/rails_spec.rb:209:in `block (4 levels) in <top (required)>'
Ruby Version
3.0.2
SDK Version
5.3.0
Integration and Its Version
Rails v6.1.4.4
Sentry Config
Sentry.init do |config|
config.rails.report_rescued_exceptions = false
end
Issue Description
Setting the
report_rescued_exceptionsoption tofalsedoesn't seem to be effective in a Rails production environment: exceptions rescued by theActionDispatch::ShowExceptionsmiddleware are reported, but as per the documentation, they shouldn't.I originally thought this bug was introduced in 7a3a86b but on closer look, I'm actually not sure this is the case. Before this commit, the
CaptureExceptionsmiddleware was wrapping theShowExceptionsmiddleware, so one would be tempted to think that if exceptions were swallowed by the latter, the former wouldn't report them. However, theShowExceptionsmiddleware sets the exception it swallows in theaction_dispatch.exceptionheader and theCaptureExceptionsmiddleware reads this value back to report the exception (regardless ofreport_rescued_exceptions).In short, I'm not sure whether this is an actual bug or whether the documentation is wrong.
Reproduction Steps
Add this spec to
sentry-rails/spec/sentry/rails_spec.rb:Expected Behavior
The spec should pass.
Actual Behavior
The spec fails with the following message:
Ruby Version
3.0.2
SDK Version
5.3.0
Integration and Its Version
Rails v6.1.4.4
Sentry Config