Skip to content

Commit

Permalink
Ignore ActionDispatch::Http::MimeNegotiation::InvalidType
Browse files Browse the repository at this point in the history
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 #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] rails/rails#35604
[3] rails/rails#40353
[4] rails/rails#35604 (comment)
  • Loading branch information
garethrees committed Oct 8, 2021
1 parent 25599b6 commit 1b6eb8f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
if notify_exceptions
ignored_exceptions = %w(
ActionController::BadRequest
ActionDispatch::Http::MimeNegotiation::InvalidType
) + ExceptionNotifier.ignored_exceptions

middleware.use ExceptionNotification::Rack,
Expand Down

0 comments on commit 1b6eb8f

Please sign in to comment.