From 7ca74e3c040b8712feee237c3eedf4e07e03201e Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Fri, 28 Aug 2026 08:06:12 +0200 Subject: [PATCH] Confirm before removing a failed mount from the repair (#180414) Co-authored-by: Paulus Schoutsen Co-authored-by: TheJulianJES --- homeassistant/components/hassio/repairs.py | 1 + homeassistant/components/hassio/strings.json | 3 + tests/components/hassio/test_repairs.py | 84 ++++++++++++++++++++ 3 files changed, 88 insertions(+) diff --git a/homeassistant/components/hassio/repairs.py b/homeassistant/components/hassio/repairs.py index 22367624ccf2..4f4b64b1c6c3 100644 --- a/homeassistant/components/hassio/repairs.py +++ b/homeassistant/components/hassio/repairs.py @@ -41,6 +41,7 @@ from .issues import Issue, Suggestion SUGGESTION_CONFIRMATION_REQUIRED = { "addon_execute_remove", + "mount_execute_remove", "mount_move_local_data", "system_adopt_data_disk", "system_execute_reboot", diff --git a/homeassistant/components/hassio/strings.json b/homeassistant/components/hassio/strings.json index 9c05ad0a6e30..603aa9411b29 100644 --- a/homeassistant/components/hassio/strings.json +++ b/homeassistant/components/hassio/strings.json @@ -159,6 +159,9 @@ "mount_move_local_data": "Move blocking local data away" } }, + "mount_execute_remove": { + "description": "Select **Submit** to remove the network storage `{reference}` from Home Assistant. Any data stored on the device itself is not affected, but automations, backups or apps relying on this storage will no longer have access to it.\n\nYou can add the network storage again later from [storage]({storage_url})." + }, "mount_move_local_data": { "description": "Select **Submit** to move the local data blocking `{reference}` to a `{reference}_local_recovery` folder and set up the mount again.\n\nNo files are deleted. For media and share mounts the recovery folder is created next to the mount, where you can review and remove it. For backup mounts it is placed in local backup storage." } diff --git a/tests/components/hassio/test_repairs.py b/tests/components/hassio/test_repairs.py index 17d45f5ef775..3ff2880637ec 100644 --- a/tests/components/hassio/test_repairs.py +++ b/tests/components/hassio/test_repairs.py @@ -705,6 +705,90 @@ async def test_mount_failed_repair_flow( supervisor_client.resolution.apply_suggestion.assert_called_once_with(sugg_uuid) +@pytest.mark.usefixtures("all_setup_requests") +async def test_mount_failed_remove_repair_flow( + hass: HomeAssistant, + supervisor_client: AsyncMock, + hass_client: ClientSessionGenerator, + issue_registry: ir.IssueRegistry, +) -> None: + """Test removing the mount from the mount_failed repair requires confirmation.""" + mock_resolution_info( + supervisor_client, + issues=[ + Issue( + type=IssueType.MOUNT_FAILED, + context=ContextType.MOUNT, + reference="backup_share", + uuid=(issue_uuid := uuid4()), + reference_extra=None, + ), + ], + suggestions_by_issue={ + issue_uuid: [ + Suggestion( + type=SuggestionType.EXECUTE_RELOAD, + context=ContextType.MOUNT, + reference="backup_share", + uuid=uuid4(), + auto=False, + reference_extra=None, + ), + Suggestion( + type=SuggestionType.EXECUTE_REMOVE, + context=ContextType.MOUNT, + reference="backup_share", + uuid=(sugg_uuid := uuid4()), + auto=False, + reference_extra=None, + ), + ] + }, + ) + + assert await async_setup_component(hass, DOMAIN, {}) + + repair_issue = issue_registry.async_get_issue( + domain="hassio", issue_id=issue_uuid.hex + ) + assert repair_issue + + client = await hass_client() + + resp = await client.post( + "/api/repairs/issues/fix", + json={"handler": "hassio", "issue_id": repair_issue.issue_id}, + ) + + assert resp.status == HTTPStatus.OK + data = await resp.json() + + flow_id = data["flow_id"] + assert data["type"] == "menu" + + resp = await client.post( + f"/api/repairs/issues/fix/{flow_id}", + json={"next_step_id": "mount_execute_remove"}, + ) + + assert resp.status == HTTPStatus.OK + data = await resp.json() + + flow_id = data["flow_id"] + assert data["type"] == "form" + assert data["step_id"] == "mount_execute_remove" + supervisor_client.resolution.apply_suggestion.assert_not_called() + + resp = await client.post(f"/api/repairs/issues/fix/{flow_id}", json={}) + + assert resp.status == HTTPStatus.OK + data = await resp.json() + + assert data["type"] == "create_entry" + assert not issue_registry.async_get_issue(domain="hassio", issue_id=issue_uuid.hex) + supervisor_client.resolution.apply_suggestion.assert_called_once_with(sugg_uuid) + + @pytest.mark.usefixtures("all_setup_requests") async def test_mount_failed_move_local_data_repair_flow( hass: HomeAssistant,