mirror of
https://github.com/home-assistant/supervisor.git
synced 2026-08-14 00:43:17 +01:00
* Gracefully end log stream when journal gateway connection is lost When systemd-journal-gatewayd is stopped while a client follows logs (e.g. on host reboot with the log viewer open), aiohttp raises ClientPayloadError and advanced_logs_handler converted it to an APIError. For the /supervisor/logs endpoints this got logged as an unexpected error with a full traceback and captured to Sentry on every occurrence (#7103, SUPERVISOR-1FHT). Once the streaming response has started, an error response can no longer be delivered anyway, so treat a lost connection to systemd-journal-gatewayd like a client-side disconnect and end the stream gracefully. The APIError is still raised when the connection is lost before any data was sent to the client. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Treat unreachable systemd-journal-gatewayd as a known API error Manual testing of the previous commit (killing systemd-journal-gatewayd while Supervisor is running) showed that every log API request hitting the dead gateway logs an "Unexpected error during API call" traceback and captures HostServiceError to Sentry (SUPERVISOR-K8C), in addition to the ERROR already logged at the raise site in journald_logs(). Make HostServiceError inherit from APIError as well, following the HostContainerLogEpochError precedent, so the api_process decorators return a plain 400 response without the redundant traceback and Sentry capture. Also treat it like HostNotSupportedError in the supervisor logs fallback wrapper: fall back to Docker container logs with a warning instead of an exception log plus Sentry capture. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Use dedicated exception for journal gateway connection errors HostServiceError is also raised by ServiceManager for systemd units called through the API (e.g. /os/config/sync), where inheriting from APIError would hide genuine service breakage from Sentry. Introduce HostJournalGatewaydConnectionError subclassing HostServiceError and APIError, and raise it for the gatewayd connection failure only, as suggested in the PR review. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>