From 3a00a6a9f27d24ed24447225e1ba030aa5a36299 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 3 Mar 2025 10:22:13 +0100 Subject: [PATCH] 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 --- supervisor/api/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/supervisor/api/__init__.py b/supervisor/api/__init__.py index fe3f17ace..83f623fa6 100644 --- a/supervisor/api/__init__.py +++ b/supervisor/api/__init__.py @@ -9,7 +9,7 @@ from aiohttp import web from ..const import AddonState from ..coresys import CoreSys, CoreSysAttributes -from ..exceptions import APIAddonNotInstalled, HostNotSupportedError +from ..exceptions import APIAddonNotInstalled, APIError, HostNotSupportedError from ..utils.sentry import async_capture_exception from .addons import APIAddons from .audio import APIAudio @@ -403,6 +403,10 @@ class RestAPI(CoreSysAttributes): return await self._api_host.advanced_logs_handler( *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 # Supervisor logs are critical, so catch everything, log the exception # and try to return Docker container logs as the fallback