Skip to content

Commit d45e53f

Browse files
authored
Ignore new rails rate limit errors (#2774)
* Ignore new rails rate_limit errors Add 'ActionController::TooManyRequests' to error list * Fix configuration to include TooManyRequests error * 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 b1cdb81 commit d45e53f

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Features
1010

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

1314
### Fixes
1415

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

Lines changed: 8 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)
@@ -50,12 +51,18 @@ module Rails
5051
"ActionController::RoutingError",
5152
"ActionController::UnknownAction",
5253
"ActionController::UnknownFormat",
53-
"ActionDispatch::Http::MimeNegotiation::InvalidType",
5454
"ActionController::UnknownHttpMethod",
55+
"ActionDispatch::Http::MimeNegotiation::InvalidType",
5556
"ActionDispatch::Http::Parameters::ParseError",
5657
"ActiveRecord::RecordNotFound"
5758
].freeze
5859

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+
5966
ACTIVE_SUPPORT_LOGGER_SUBSCRIPTION_ITEMS_DEFAULT = {
6067
# action_controller
6168
"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)