Repository navigation
Keep the real status code on rendered error pages - #465
Merged
Merged
Conversation
The error middleware rendered error.html for every HTTPException but returned it with status 200, so a 404 or 403 looked like a success to health probes, monitoring and Sentry. Pass the exception's status to the renderer, and let redirects raised as exceptions pass through.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while preparing the cabotage deployment (#464): over the socket,
GET /nopeanswered200 OKwith the error page.error_middlewarecatches everyHTTPException, renderserror.html, and returns it with the renderer's default status 200. That hides real errors from cabotage's probes, from anything watching response codes, and from Sentry.Changes
status=ex.statustorender_template, so a 404 stays a 404 and the CSRF failure stays a 403. The page content is unchanged.HTTPExceptions below 400 (redirects) pass through instead of being rendered as an error page. Nothing in the app raises one today, all redirects are returned, so this only guards against a future mistake.HTTPForbidden, and a raised redirect.