-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails 5.1 showing wrong error message when routing error happens #28892
Comments
Example app https://github.com/prathamesh-sonpatki/blog-5-1 |
Looks like related to 2eb0a6630ac as now we are trying to load controller_class and in this case, the controller class does not exist. |
cc @tenderlove |
I'll take a look. My guess is that the routing error middleware is at the wrong level. In this case maybe we should explicitly render the routing error (rather than having a middleware catch an exception somehow) |
When you have a route that points to an nonexistent controller we raise an exception. This exception was being caught by the DebugExceptions middleware in development, but when trying to render the error page, we are reading the request format[[1][]]. To determine the request format we are reading the format parameters[[2][]], and to be able to read the parameters we need to encode them[[3][]]. This was raising another exception that to encode the parameter we try to load the controller to determine if we need to encode the parameters are binary[[4][]]. This new exception inside the DebugExceptions middleware makes Rails to render a generic error page. To avoid this new exception now we only encode the parameters when the controller can be loaded. Fixes rails#28892 [1]: https://github.com/rails/rails/blob/f52cdaac6336f99d13622ff9bda556a3124a4121/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb#L80 [2]: https://github.com/rails/rails/blob/f52cdaac6336f99d13622ff9bda556a3124a4121/actionpack/lib/action_dispatch/http/mime_negotiation.rb#L63 [3]: https://github.com/rails/rails/blob/f52cdaac6336f99d13622ff9bda556a3124a4121/actionpack/lib/action_dispatch/http/parameters.rb#L58 [4]: https://github.com/rails/rails/blob/f52cdaac6336f99d13622ff9bda556a3124a4121/actionpack/lib/action_dispatch/http/parameters.rb#L88
Steps to reproduce
rails new blog --dev # pointing to 5-1-stable
edit config/routes.rb and add
resources :articles
rails s
visit localhost:3000/articles/new
Shows error: http://take.ms/GSbZ9
On Rails 5.0.2, it shows proper routing error: https://monosnap.com/file/hDZjt99m2vkXe3kP9K1hxhz0uALq1f
Puma version: 3.8.2
Stacktrace: https://gist.github.com/prathamesh-sonpatki/c2f97d0540adbc9562171b9a0787b39a
Looks like it is rendering the FAILSAFE response but not sure why.
Found this while following the steps from getting started guide on the new app created from 5-1-stable branch.
cc @rafaelfranca
The text was updated successfully, but these errors were encountered: