Skip to content

fix(sentry): drop offline-device gaierror events in before_send#3132

Merged
vpetersson merged 2 commits into
masterfrom
fix/sentry-drop-offline-gaierror
Jul 7, 2026
Merged

fix(sentry): drop offline-device gaierror events in before_send#3132
vpetersson merged 2 commits into
masterfrom
fix/sentry-drop-offline-gaierror

Conversation

@vpetersson

@vpetersson vpetersson commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Issues Fixed

Description

A device without working DNS (offline, captive portal, upstream outage) reported gaierror: [Errno -5] No address associated with hostname to Sentry on every attempted external call — 253 events in under a day from a single pi3-64. Every one of those events is the asyncio Future exception was never retrieved error 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.gaierror to the before_send transient-drop list, chain-checked like the redis errors so requests-wrapped resolution failures (urllib3 NameResolutionErrorrequests.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_send with a socket.gaierror returned None (event dropped), while a real ValueError was kept — confirming the filter drops offline noise without swallowing genuine bugs. Server-side and arch-independent.

Checklist

  • I have performed a self-review of my own code.
  • New and existing unit tests pass locally and on CI with my changes.
  • I have done an end-to-end test for Raspberry Pi devices.
  • I have tested my changes for x86 devices.
  • I added a documentation for the changes I have made (when necessary).

🤖 Generated with Claude Code

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>
@vpetersson vpetersson requested a review from a team as a code owner July 7, 2026 17:06
@vpetersson vpetersson self-assigned this Jul 7, 2026
@vpetersson vpetersson requested a review from Copilot July 7, 2026 17:06

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 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.gaierror to the transient-drop list in _sentry_before_send, using the existing exception-chain walk.
  • Add unit tests ensuring raw and wrapped gaierror events 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.

Comment thread tests/test_sentry.py Outdated
Comment thread src/anthias_server/django_project/settings.py
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>
@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@vpetersson vpetersson merged commit 435a8dc into master Jul 7, 2026
10 checks passed
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.

Sentry noise: offline devices report gaierror per network call, 253/day (Sentry ANTHIAS-3G)

2 participants