Repository navigation
fix(cloudflare): Return HTTPException responses instead of 500 - #1775
Open
sentry-junior[bot] wants to merge 2 commits into
Open
sentry-junior[bot] wants to merge 2 commits into
sentry-junior[bot] wants to merge 2 commits into
Conversation
The app onError handler turned every error into a 500 and reported it with logIssue, including HTTPException(403) thrown by csrf() for cross-site form POSTs. Return the exception's own response and only report server-error statuses. Co-Authored-By: David Cramer <david@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
CSRF rejections and other 4xx HTTPExceptions now emit a warn-level "HTTP exception response" log entry (Sentry Logs, not an issue) with status, method, path, Origin, Sec-Fetch-Site, and Content-Type. csrf() rejections are tagged so the entry carries app.http_exception.reason=csrf. Co-Authored-By: David Cramer <david@sentry.io>
BYK
approved these changes
Nov 1, 2026
BYK
marked this pull request as ready for review
November 1, 2026 15:02
This branch was previously deployed
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.
Cross-site form POSTs to the Cloudflare app, mostly bots and scanners hitting paths that don't exist, come back as 500s. Each one also creates a Sentry error event. That is the source of MCP-SERVER-GDZ.
csrf()is mounted on*and throwsHTTPException(403)when it rejects a request. The app'sonErrorhandler did not check forHTTPException. It calledlogIssueon every error and returned a generic 500. A CSRF rejection that should be a 403 became a reported server error. This also affects real browser CSRF failures onPOST /oauth/authorize./oauth/tokenis handled by the OAuth provider before the app, so it is not affected.onErrornow returnserr.getResponse()forHTTPException, and callslogIssueonly when the status is 5xx. Other errors still get a 500 and are reported as before.The 4xx rejections are still kept so they can be audited. Each one writes a warn-level
HTTP exception responselog entry to Sentry Logs. That is a log entry, not an issue. It records the status, method, path,Origin,Sec-Fetch-SiteandContent-Type. A header that wasn't sent is recorded as(absent). It records no IPs, cookies, auth headers or bodies. The csrf middleware is wrapped so its rejections are taggedapp.http_exception.reason=csrf, which makes them searchable. Any other 4xxHTTPExceptionis logged withreason=unknown.Three changes to
app.test.ts:logIssue, and writes the audit log entry with the expected fields.via David Cramer.
--
View Session [Sentry]