Fix regression in Honeybadger.config.exceptions.ignore (#12796)

This commit is contained in:
rhymes 2021-02-23 19:08:29 +01:00 committed by GitHub
parent d481c6971c
commit 351d4f8da7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View file

@ -12,6 +12,13 @@ COMPONENT_FINGERPRINTS = {
"internal" => "internal"
}.freeze
HONEYBADGER_EXCEPTIONS_TO_IGNORE = [
ActiveRecord::QueryCanceled,
ActiveRecord::RecordNotFound,
Pundit::NotAuthorizedError,
RateLimitChecker::LimitReached,
].freeze
Rails.application.reloader.to_prepare do
# https://docs.honeybadger.io/lib/ruby/gem-reference/configuration.html
Honeybadger.configure do |config|
@ -25,8 +32,8 @@ Rails.application.reloader.to_prepare do
# Logging allows us to fill in gaps if we need to when errors get discarded.
config.send_data_at_exit = false
config.exceptions.ignore +=
config.request.filter_keys += %w[authorization]
config.exceptions.ignore += HONEYBADGER_EXCEPTIONS_TO_IGNORE
config.request.filter_keys += %w[authorization]
config.sidekiq.attempt_threshold = 10
config.breadcrumbs.enabled = true

View file

@ -5,6 +5,20 @@ describe Honeybadger do
include_examples "#sets_correct_honeybadger_fingerprint", error_key, fingerprint
end
context "when configuration is loaded" do
it "ignores requested exceptions" do
exceptions_to_ignore = [
ActiveRecord::QueryCanceled,
ActiveRecord::RecordNotFound,
Pundit::NotAuthorizedError,
RateLimitChecker::LimitReached,
]
ignored_exceptions = described_class.config.ruby[:"exceptions.ignore"]
expect(exceptions_to_ignore.all? { |e| ignored_exceptions.include?(e) }).to be(true)
end
end
context "when error is raised from an internal route" do
it "sets fingerprint to internal" do
notice = Honeybadger::Notice.new(