From 1b6eb8fe5e8137c6291dd740354ff59a67beed57 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Fri, 8 Oct 2021 09:46:46 +0100 Subject: [PATCH] Ignore ActionDispatch::Http::MimeNegotiation::InvalidType This expcetion was added between Rails 5.2 and 6.0 [1] in #35604 [2] and #40353. Under Rails 6, in development a 406 HTTP status is returned: > curl -I -H "Content-Type: *" http://localhost:3000 HTTP/1.1 406 Not Acceptable In production, we also get a 406: > curl -I -H "Content-Type: *" https://www.whatdotheyknow.com/cy/request/merthy_road_whitchurch_cardiff HTTP/2 406 This appears to be the correct behaviour and in the PRs above the Rails core team suggest ignoring these exceptions [4]. > You're right that it's not something you can fix which is why we > suggest ignoring it for exception monitoring services like Appsignal, > Sentry and Bugsnag but it's still logged so you can go back and > analyse things if necessary. Fixes https://github.com/mysociety/alaveteli/issues/6553. Hat tip to @gbp for the investigation and explanation included in this commit message. [1] https://github.com/rails/rails/blob/1b5658b562b29f8aab7e80cbab8adbd2ddea5447/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb#L15 [2] https://github.com/rails/rails/pull/35604 [3] https://github.com/rails/rails/pull/40353 [4] https://github.com/rails/rails/pull/35604#issuecomment-835274505 --- config/environments/production.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/environments/production.rb b/config/environments/production.rb index 86ad6c7479..afa31643d6 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -131,6 +131,7 @@ if notify_exceptions ignored_exceptions = %w( ActionController::BadRequest + ActionDispatch::Http::MimeNegotiation::InvalidType ) + ExceptionNotifier.ignored_exceptions middleware.use ExceptionNotification::Rack,