fix(sentry): drop client-disconnect static-file noise - #3182
Merged
vpetersson merged 1 commit intoJul 10, 2026
Conversation
A client that hangs up mid-response while Django's ASGI handler is still
streaming a static file (WhiteNoise serving e.g. the splash SVG as the
viewer navigates away) makes Django raise
RuntimeError("Response content shorter than Content-Length") — a broken
pipe, not a truncated file. Same client-disconnect class as the
CancelledError we already drop, but it surfaces as a bare RuntimeError.
Add it to _sentry_before_send, matched by message text so unrelated
RuntimeErrors are not swallowed (Sentry ANTHIAS-37).
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
There was a problem hiding this comment.
Pull request overview
This PR reduces benign Sentry noise by dropping a specific Django/ASGI client-disconnect failure that surfaces as RuntimeError: Response content shorter than Content-Length, while explicitly preserving unrelated RuntimeErrors.
Changes:
- Extend
_sentry_before_sendto dropRuntimeErrorinstances only when their message containsResponse content shorter than Content-Length. - Add regression tests to ensure the targeted RuntimeError is dropped and other RuntimeErrors are still reported.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/test_sentry.py | Adds regression coverage for dropping the specific short-Content-Length RuntimeError while keeping unrelated RuntimeErrors. |
| src/anthias_server/django_project/settings.py | Updates Sentry before_send filter to drop the targeted client-disconnect RuntimeError by message substring. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.



What
Adds
RuntimeError: Response content shorter than Content-Lengthto the_sentry_before_senddrop-list, matched by message text.Why
A client that hangs up mid-response while Django's ASGI handler is still streaming a static file (WhiteNoise serving e.g.
logo-full-splash.svgas the viewer navigates away) makes Django declare aContent-Lengthfrom the file size and then have the transfer cut short by the disconnect — a broken pipe, not a truncated file. It is the same benign client-disconnect class as theasyncio.CancelledErroralready dropped here, but it surfaces as a bareRuntimeError(ANTHIAS-37, pi4-64).How
Match
isinstance(exc, RuntimeError) and 'Response content shorter than Content-Length' in str(exc). The message scope keeps it from swallowing unrelated RuntimeErrors.Tests
TestBeforeSendTransientNoisegains two cases: the short-Content-Length RuntimeError is dropped; an unrelated RuntimeError is kept.🤖 Generated with Claude Code