1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2026-05-26 17:45:15 +01:00
Files
supervisor/tests/addons
Stefan Agner 641a4181d9 Handle add-on filesystem errors gracefully and reduce Sentry noise (#6707)
* Handle add-on filesystem errors gracefully and reduce Sentry noise

Add AddonFileReadError for add-on metadata read failures (long_description,
refresh_path_cache) caused by filesystem errors like EBADMSG (errno 74).
The new exception calls check_oserror() to mark the system unhealthy via
the resolution system, then raises a translatable API error so callers
get a proper error response instead of an unhandled OSError.

Fixes SUPERVISOR-BC6 (548K events from the API path) and
SUPERVISOR-BZJ (from the startup/load path).

In core.py setup(), skip reporting exceptions to Sentry when the error
has already been handled by the resolution system. This is detected by
checking if a new unhealthy reason was added during the task execution
(e.g. via check_oserror). In that case the user is already notified, so
we log at error level (no stack trace) instead of critical (which would
also send to Sentry via the LoggingIntegration) and skip the explicit
capture_exception call.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Skip Sentry capture for AppFileReadError in setup()

Replace the unhealthy-state comparison logic with an explicit
`except AppFileReadError` clause. The error is already reported to
the user via the resolution system (check_oserror adds an unhealthy
reason), so capturing it to Sentry just adds noise.

Log at error level without stack trace instead of critical to avoid
the LoggingIntegration picking it up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Add tests for AppFileReadError and setup() Sentry handling

Test that long_description and refresh_path_cache raise AppFileReadError
and mark the system unhealthy for EBADMSG errors, and raise without
marking unhealthy for other OSError types.

Also test Core.setup() to verify AppFileReadError is handled without
Sentry capture while other exceptions are captured as before.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-29 10:10:36 +02:00
..