Skip to content

fix: selectively downgrade expected errors from Error to Warn#568

Merged
wizzomafizzo merged 3 commits intomainfrom
fix/sentry-noise-log-level-downgrades
Mar 19, 2026
Merged

fix: selectively downgrade expected errors from Error to Warn#568
wizzomafizzo merged 3 commits intomainfrom
fix/sentry-noise-log-level-downgrades

Conversation

@wizzomafizzo
Copy link
Member

Summary

  • Sentry noise reduction: 8 of 10 reported error groups are expected operational conditions logged at Error level, inflating Sentry noise and masking real issues
  • Selectively downgrade known expected errors to Warn using sentinel errors and errors.Is(), keeping Error level for unexpected/unknown errors in all paths
  • Add ErrNoControlCapabilities sentinel error for launchers without control support
  • Add logWSWriteError helper for consistent WebSocket write error handling across all write sites (response, broadcast, pong, panic recovery)

Errors addressed:

# Error Approach
1 PN532 wake-up failure (device gone) pn532.IsFatal() → Warn
2 WebSocket "session is closed" melody.ErrSessionClosed → Warn
3+4 TUI API timeout burst Notification handler → Warn, startup stays Error
6 API client closed connection net.ErrClosed → Warn
8+9 Title not found (Metal Slug X) titles.ErrNoMatch → Warn
10 Genesis no control capabilities ErrNoControlCapabilities → Warn

Not changed: #5 (TTY stuck — deferred, monitoring), #7 (log upload 403 — keep Error for visibility)

Sentry noise reduction: 8 of 10 reported error groups are expected
operational conditions (hardware disconnects, client disconnects,
title-not-found, unsupported control commands) logged at Error level.

Selective downgrades using sentinel errors and errors.Is():
- PN532: fatal hardware errors (device gone) via pn532.IsFatal()
- WebSocket: session closed via melody.ErrSessionClosed
- API client: closed connection via net.ErrClosed
- TUI: notification handler GetReaders timeout (startup call stays Error)
- ZapScript: title not found (titles.ErrNoMatch) and no control
  capabilities (new ErrNoControlCapabilities sentinel)

Unexpected/unknown errors remain at Error level in all paths.
@sentry
Copy link

sentry bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 54.54545% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/api/server.go 64.28% 5 Missing ⚠️
pkg/ui/tui/main.go 0.00% 5 Missing ⚠️
pkg/zapscript/commands.go 0.00% 3 Missing ⚠️
pkg/api/client/client.go 50.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Add TestLogWSWriteError (server_logging_test.go):
- Verifies melody.ErrSessionClosed logs at warn level
- Verifies wrapped session closed errors log at warn level
- Verifies other errors log at error level

Add TestLogTraceableError (pn532_test.go):
- Verifies context.Canceled logs at debug level
- Verifies fatal hardware errors (ErrDeviceNotFound, ErrTransportClosed) log at warn level
- Verifies other errors log at error level
Add TestHandlePostRequest_ExpectedError (server_post_test.go):
- Covers the ErrNoControlCapabilities warn-level branch in handleRequest

Expand TestLogTraceableError (pn532_test.go):
- Add wire trace case verifying transport/port/trace data is logged
@wizzomafizzo wizzomafizzo merged commit e5edae9 into main Mar 19, 2026
10 checks passed
@wizzomafizzo wizzomafizzo deleted the fix/sentry-noise-log-level-downgrades branch March 19, 2026 10:01
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.

1 participant