Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Make sure Rails will always raise `ActionController::RoutingError` when show_exceptions is set to false

#6462

Refer to this StackOverflow question: http://stackoverflow.com/questions/5022454/raising-route-not-found-...

I just found that there's a bug in Rails since April 2010 that if you set the config.action_dispatch.show_exceptions to false you wouldn't get ActionController::RoutingError because the middleware that supposed to raise the exception, ActionDispatch::ShowExceptions doesn't get loaded if the config.action_dispatch.show_exceptions is set to false.

This patch will make sure that the middleware will always get loaded. So if the middleware down the stack returns a "X-Cascade: pass" header, it will raise the ActionController::RoutingError as expected.

I've separate the patches into three commits:

  1. Make sure that we set env["action_dispatch.show_exceptions"]
  2. Add failing test case for application not raising ActionController::RoutingError even the route is not found.
  3. Always use ActionDispatch::ShowExceptions middleware

I would love to see this got committed in both master and 3-0-stable as there's already someone on 3.0.x came across this bug while doing test driven development.

Thank you.

Reported by Prem Sichanugrist (sikachu) · February 22nd, 2011 @ 08:16 PM

State: resolved
Milestone: 3.x
Assigned to: Aaron Patterson Aaron Patterson
Importance: Medium

Activity

  1. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • Assigned user changed from José Valim to Aaron Patterson

    I've updated the patch and rebase 002+003 together, per Aaron request

    February 24th, 2011 @ 05:22 PM

  2. Aaron Patterson
    Aaron Patterson

    Prem, can you also backport these to 3.0 for me? Sorry, I'm feeling lazy. ;-)

    February 24th, 2011 @ 07:49 PM

  3. Prem Sichanugrist (sikachu)
  4. Aaron Patterson
    Aaron Patterson
    • State changed from open to committed

    applied and pushed, thanks!

    February 25th, 2011 @ 06:45 PM

  5. Repository
    Repository
    • State changed from committed to resolved

    (from [2a67e69f1ff8960c4b4190c3189e2ab7250b4faf]) Always use ActionDispatch::ShowExceptions middleware [#6462 Make sure Rails will always raise `ActionController::RoutingError` when show_... state:resolved]

    This will make sure the application will raise ActionController::RoutingError in case "X-Cascade: pass" header was set, usually when there's no route match.

    (This is a backported version to 3-0-stable) https://github.com/rails/rails/commit/2a67e69f1ff8960c4b4190c3189e2...

    February 25th, 2011 @ 06:46 PM

  6. Repository
    Repository

    (from [515ea955b6a80ab9f527ad0f6dcc25a17688a02c]) Always use ActionDispatch::ShowExceptions middleware [#6462 Make sure Rails will always raise `ActionController::RoutingError` when show_... state:resolved]

    This will make sure the application will raise ActionController::RoutingError in case "X-Cascade: pass" header was set, usually when there's no route match.
    https://github.com/rails/rails/commit/515ea955b6a80ab9f527ad0f6dcc2...

    February 25th, 2011 @ 06:46 PM