Skip to content

fix(sentry): drop client-disconnect static-file noise - #3182

Merged
vpetersson merged 1 commit into
masterfrom
fix/anthias-37-drop-short-content-length-noise
Jul 10, 2026
Merged

fix(sentry): drop client-disconnect static-file noise#3182
vpetersson merged 1 commit into
masterfrom
fix/anthias-37-drop-short-content-length-noise

Conversation

@vpetersson

Copy link
Copy Markdown
Contributor

What

Adds RuntimeError: Response content shorter than Content-Length to the _sentry_before_send drop-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.svg as the viewer navigates away) makes Django declare a Content-Length from 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 the asyncio.CancelledError already dropped here, but it surfaces as a bare RuntimeError (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

TestBeforeSendTransientNoise gains two cases: the short-Content-Length RuntimeError is dropped; an unrelated RuntimeError is kept.

🤖 Generated with Claude Code

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]>
@vpetersson
vpetersson requested a review from a team as a code owner July 10, 2026 08:38
@vpetersson
vpetersson requested a review from Copilot July 10, 2026 08:39
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_send to drop RuntimeError instances only when their message contains Response 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.

@vpetersson
vpetersson merged commit f01df0c into master Jul 10, 2026
10 checks passed
@vpetersson
vpetersson deleted the fix/anthias-37-drop-short-content-length-noise branch July 10, 2026 09:44
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.

2 participants