Skip to content

Commit 775d6f9

Browse files
committed
feat: Ignore ActionController::TooManyRequests for Rails 8.1.1+
Add Rails 8.1.1 rate limiting error to excluded exceptions conditionally. Only applies when Rails version >= 8.1.1.
1 parent 87d2526 commit 775d6f9

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Features
44

55
- Include otel as custom sampling context ([2683](https://github.com/getsentry/sentry-ruby/pull/2683))
6+
- Ignore new rails rate limit errors ([#2774](https://github.com/getsentry/sentry-ruby/pull/2774))
67

78
## 6.1.2
89

sentry-rails/lib/sentry/rails/configuration.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Configuration
1515
after(:initialize) do
1616
@rails = Sentry::Rails::Configuration.new
1717
@excluded_exceptions = @excluded_exceptions.concat(Sentry::Rails::IGNORE_DEFAULT)
18+
@excluded_exceptions = @excluded_exceptions.concat(Sentry::Rails::RAILS_8_1_1_IGNORE_DEFAULT) if Gem::Version.new(::Rails.version) >= Gem::Version.new("8.1.1")
1819

1920
if ::Rails.logger
2021
if defined?(::ActiveSupport::BroadcastLogger) && ::Rails.logger.is_a?(::ActiveSupport::BroadcastLogger)
@@ -48,7 +49,6 @@ module Rails
4849
"ActionController::NotImplemented",
4950
"ActionController::ParameterMissing",
5051
"ActionController::RoutingError",
51-
"ActionController::TooManyRequests",
5252
"ActionController::UnknownAction",
5353
"ActionController::UnknownFormat",
5454
"ActionController::UnknownHttpMethod",
@@ -57,6 +57,12 @@ module Rails
5757
"ActiveRecord::RecordNotFound"
5858
].freeze
5959

60+
# Rails 8.1.1 introduced ActionController::TooManyRequests for rate limiting
61+
# https://github.com/rails/rails/commit/73ecd0ced634e5177496677a2986ec3731c7e2ee
62+
RAILS_8_1_1_IGNORE_DEFAULT = [
63+
"ActionController::TooManyRequests"
64+
].freeze
65+
6066
ACTIVE_SUPPORT_LOGGER_SUBSCRIPTION_ITEMS_DEFAULT = {
6167
# action_controller
6268
"write_fragment.action_controller" => %i[key],

sentry-rails/spec/sentry/rails/configuration_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
expect(config.excluded_exceptions).to include("ActiveRecord::RecordNotFound")
1616
end
1717

18+
it "ignores ActionController::TooManyRequests by default on Rails 8.1.1+", skip: Gem::Version.new(Rails.version) < Gem::Version.new("8.1.1") do
19+
config = Sentry::Configuration.new
20+
21+
expect(config.excluded_exceptions).to include("ActionController::TooManyRequests")
22+
end
23+
1824
describe "#report_rescued_exceptions" do
1925
it "has correct default value" do
2026
expect(subject.report_rescued_exceptions).to eq(true)

0 commit comments

Comments
 (0)