Skip to content

Commit

Permalink
Ignore notifying ActionController::BadRequest errors
Browse files Browse the repository at this point in the history
HTTP requests with bad characters are correctly handled returning a bad
request (400 code) error. We don't need to be notified about wrong HTTP
requests.

Also sort elements of the array. Make it more readable and easier to
find elements while inspecting the code.
  • Loading branch information
eduardoj committed Mar 25, 2024
1 parent e382458 commit df8f09a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/api/config/initializers/airbrake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ def ignore_by_backend_400_message?(message)
end

def ignore_by_class?(notice)
exceptions_to_ignore = ['ActiveRecord::RecordNotFound', 'ActionController::InvalidAuthenticityToken',
'CGI::Session::CookieStore::TamperedWithCookie', 'ActionController::UnknownAction',
'AbstractController::ActionNotFound', 'Bunny::TCPConnectionFailedForAllHosts',
'Timeout::Error', 'Net::HTTPBadResponse', 'Errno::ECONNRESET', 'Interrupt',
'RoutesHelper::WebuiMatcher::InvalidRequestFormat', 'ActionDispatch::Http::MimeNegotiation::InvalidType',
'ActionController::UnknownFormat', 'Backend::NotFoundError', 'AMQ::Protocol::EmptyResponseError']
exceptions_to_ignore = ['AMQ::Protocol::EmptyResponseError', 'AbstractController::ActionNotFound',
'ActionController::BadRequest', 'ActionController::InvalidAuthenticityToken',
'ActionController::UnknownAction', 'ActionController::UnknownFormat',
'ActionDispatch::Http::MimeNegotiation::InvalidType',
'ActiveRecord::RecordNotFound', 'Backend::NotFoundError',
'Bunny::TCPConnectionFailedForAllHosts', 'CGI::Session::CookieStore::TamperedWithCookie',
'Errno::ECONNRESET', 'Interrupt', 'Net::HTTPBadResponse',
'RoutesHelper::WebuiMatcher::InvalidRequestFormat', 'Timeout::Error']

notice[:errors].pluck(:type).intersect?(exceptions_to_ignore)
end
Expand Down

0 comments on commit df8f09a

Please sign in to comment.