fix(sentry): drop offline-device gaierror events in before_send#3132
Merged
Conversation
A DNS-less device (offline / captive network) burned a Sentry event per attempted external call — 253/day from one pi3-64, mostly via asyncio's "Future exception was never retrieved" error log. Being offline is a routine state for signage, not a bug. Chain-checked like the redis transients so requests-wrapped resolution failures (urllib3 NameResolutionError -> requests.ConnectionError) are dropped too. Fixes #3126 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR reduces Sentry noise for offline/captive-portal devices by dropping DNS-resolution failures (socket.gaierror, including when wrapped by higher-level HTTP exceptions) in the Sentry before_send hook.
Changes:
- Add
socket.gaierrorto the transient-drop list in_sentry_before_send, using the existing exception-chain walk. - Add unit tests ensuring raw and wrapped
gaierrorevents are dropped.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/anthias_server/django_project/settings.py |
Drops socket.gaierror (and chained/wrapped instances) in Sentry before_send; updates docstring rationale. |
tests/test_sentry.py |
Adds regression tests verifying gaierror and wrapped gaierror events are filtered out. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot review: the before_send docstring said "two classes" while listing four, and the wrapped-gaierror test mutated __cause__ instead of raising from the root like the sibling tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
This was referenced Jul 8, 2026
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.



Issues Fixed
Description
A device without working DNS (offline, captive portal, upstream outage) reported
gaierror: [Errno -5] No address associated with hostnameto Sentry on every attempted external call — 253 events in under a day from a single pi3-64. Every one of those events is the asyncioFuture exception was never retrievederror log inside uvicorn, with no stack trace, so there's nothing actionable in them; being offline is a routine operating state for a signage device.This adds
socket.gaierrorto thebefore_sendtransient-drop list, chain-checked like the redis errors sorequests-wrapped resolution failures (urllib3NameResolutionError→requests.ConnectionError) are dropped too. Same policy precedent as the redis blips (ANTHIAS-M/K/H/J), client disconnects (ANTHIAS-N), and AuthSettingsError (ANTHIAS-3D).Follow-up worth tracking separately: something in the ASGI process abandons an asyncio future that resolves with the DNS error (that's how these surface as "Future exception was never retrieved"). Pinning down the creator needs a live offline-device repro; this PR stops the fleet-wide quota burn regardless of the source.
Validation on real hardware
Exercised in the real server container on the x86 testbed:
_sentry_before_sendwith asocket.gaierrorreturnedNone(event dropped), while a realValueErrorwas kept — confirming the filter drops offline noise without swallowing genuine bugs. Server-side and arch-independent.Checklist
🤖 Generated with Claude Code