自从升级到Rails 6以来,我们开始出现以下错误:Mime::Type::InvalidMimeType ("charset=utf-8" is not a valid MIME type)
。我认为charset=utf-8
作为MIME类型没有任何意义,但无法挽救这些错误:
rescue_from Mime::Type::InvalidMimeType, with: :raise_not_found
这个异常是否有可能在击中我们的控制器之前引发?
Mime::Type::InvalidMimeType
是用这个PR添加的:https://github.com/rails/rails/pull/35753
This PR adds the InvalidMimeType in the default rescue_responses from
the ExceptionWrapper and will return a 406.
关于rescue_responses
: https://guides.rubyonrails.org/configuring.html#configuring-action-dispatch
您是否尝试过以下解决方案:https://stackoverflow.com/a/52475865/4414956?猴子修补或从rescue_responses中删除无效的MimeType并自行处理。