Skip to content
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

Closed
prathamesh-sonpatki opened this issue Apr 26, 2017 · 4 comments
Closed
Assignees
Milestone

Comments

@prathamesh-sonpatki
Copy link
Member

prathamesh-sonpatki commented Apr 26, 2017

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

@prathamesh-sonpatki prathamesh-sonpatki added this to the 5.1.0 milestone Apr 26, 2017
@prathamesh-sonpatki
Copy link
Member Author

@prathamesh-sonpatki
Copy link
Member Author

Looks like related to 2eb0a6630ac as now we are trying to load controller_class and in this case, the controller class does not exist.

@vipulnsward
Copy link
Member

cc @tenderlove

@tenderlove
Copy link
Member

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)

@tenderlove tenderlove self-assigned this Apr 26, 2017
rafaelfranca added a commit to rafaelfranca/omg-rails that referenced this issue Apr 27, 2017
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants