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

Fix 404 errors showing up as 500 errors #4774

Merged
merged 1 commit into from
Nov 11, 2024
Merged

Conversation

dorner
Copy link
Collaborator

@dorner dorner commented Nov 10, 2024

Fixes #4765 .

First off, note that this error can only be reproduced on local if you change

  config.consider_all_requests_local = true

in development.rb to false.

The reason that a redirect to /404 happens is because of this line in application.rb:

    config.exceptions_app = routes

This forwards the error logic to the router, which redirects to a route that matches e.g. /404. When this happens, we lose all information about the route that couldn't be found. We also end up with a very bad-looking 500 error if the user isn't logged in.

I've removed this line so that Rails goes back to the default path of showing the file in public/404.html etc. I copy-pasted the end result of the current logic to show the static page that shows up regardless of whether the user is logged in or not. Sample for 500 below.

image

@dorner dorner requested a review from awwaiid November 10, 2024 15:39
Copy link
Collaborator

@awwaiid awwaiid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move forward with this; separately maybe we should look at trimming down the javascript payload on the error pages.

Thanks for the notes, TIL several details from them!

@awwaiid awwaiid merged commit ba99d54 into main Nov 11, 2024
22 checks passed
@awwaiid awwaiid deleted the 4765-fix-500-error-on-404 branch November 11, 2024 14:27
Copy link
Contributor

@dorner: Your PR Fix 404 errors showing up as 500 errors is part of today's Human Essentials production release: 2024.11.13.
Thank you very much for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigation and possible rework how we do 404 errors
2 participants