Avoid stack traces for known advanced logs errors

Known advanced errors, like connection reset, should not lead to stack
traces in the Supervisor logs. Let those errors bubble up to the
API error handling.

Fixes: #5606
This commit is contained in:
Stefan Agner 2025-03-03 10:22:13 +01:00
parent 84b265a2e0
commit 3a00a6a9f2
No known key found for this signature in database
GPG Key ID: AE01353D1E44747D

View File

@ -9,7 +9,7 @@ from aiohttp import web
from ..const import AddonState from ..const import AddonState
from ..coresys import CoreSys, CoreSysAttributes from ..coresys import CoreSys, CoreSysAttributes
from ..exceptions import APIAddonNotInstalled, HostNotSupportedError from ..exceptions import APIAddonNotInstalled, APIError, HostNotSupportedError
from ..utils.sentry import async_capture_exception from ..utils.sentry import async_capture_exception
from .addons import APIAddons from .addons import APIAddons
from .audio import APIAudio from .audio import APIAudio
@ -403,6 +403,10 @@ class RestAPI(CoreSysAttributes):
return await self._api_host.advanced_logs_handler( return await self._api_host.advanced_logs_handler(
*args, identifier="hassio_supervisor", **kwargs *args, identifier="hassio_supervisor", **kwargs
) )
except APIError as err:
# Advanced logs are generally available, but we did encounter an error
# (e.g. connection reset). Those errors should bubble up to the API.
raise err
except Exception as err: # pylint: disable=broad-exception-caught except Exception as err: # pylint: disable=broad-exception-caught
# Supervisor logs are critical, so catch everything, log the exception # Supervisor logs are critical, so catch everything, log the exception
# and try to return Docker container logs as the fallback # and try to return Docker container logs as the fallback