From 78353220de4ab4a65fd49b64245ada9ad2e219e3 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 27 Oct 2025 11:36:25 +0100 Subject: [PATCH 1/3] Reject Core Backup if sending backup start WebSocket message fails If sending the WebSocket message to Home Assistant Core to inform it about the start of a backup fails, we should reject the backup process entirely. This prevents taking a backup without Home Assistant Core being aware of it. As a side effect, this likely prevents situation where Core does not learn about the backup progress since we also won't be able to send WebSocket messages about Job progress updates. --- supervisor/homeassistant/module.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/supervisor/homeassistant/module.py b/supervisor/homeassistant/module.py index 9f2cba6b25c..f5e0b91798e 100644 --- a/supervisor/homeassistant/module.py +++ b/supervisor/homeassistant/module.py @@ -371,6 +371,12 @@ async def begin_backup(self) -> None: _LOGGER.error, ) from err + if not resp: + raise HomeAssistantBackupError( + "Preparing backup of Home Assistant Core failed. No response from HA Core.", + _LOGGER.error, + ) + if resp and not resp.get(ATTR_SUCCESS): raise HomeAssistantBackupError( f"Preparing backup of Home Assistant Core failed due to: {resp.get(ATTR_ERROR, {}).get(ATTR_MESSAGE, '')}. Check HA Core logs.", From e4959b4f108c10bb596200366b75289e31eaa20c Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 27 Oct 2025 11:46:04 +0100 Subject: [PATCH 2/3] Log rejected WebSocket messages to Home Assistant Core --- supervisor/homeassistant/websocket.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/supervisor/homeassistant/websocket.py b/supervisor/homeassistant/websocket.py index 6f8f2faf12f..52dd0ab87a7 100644 --- a/supervisor/homeassistant/websocket.py +++ b/supervisor/homeassistant/websocket.py @@ -225,6 +225,10 @@ async def _can_send(self, message: dict[str, Any]) -> bool: # since it makes a new socket connection and we already have one. if not connected and not await self.sys_homeassistant.api.check_api_state(): # No core access, don't try. + _LOGGER.debug( + "Home Assistant API is not accessible. Not sending WS message: %s", + message, + ) return False if not self._client: From 5d9d33c9fa76336107ff677e21df7b0090cd9406 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 27 Oct 2025 12:36:48 +0100 Subject: [PATCH 3/3] Wait for Home Assistant Core to start --- .github/workflows/builder.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml index 2ef857f97b3..f5788757efb 100644 --- a/.github/workflows/builder.yml +++ b/.github/workflows/builder.yml @@ -320,6 +320,15 @@ jobs: exit 1 fi + - name: Wait for Home Assistant Core to start + run: | + echo "Waiting for Home Assistant Core to start" + timeout 10m ha supervisor logs -f -n 10000 -b 0 | grep -q "Detect a running Home Assistant instance" + if [ "$?" != "0" ]; then + echo "Home Assistant Core did not start within 10 minutes" + exit 1 + fi + - name: Create full backup id: backup run: |