Confirm before removing a failed mount from the repair (#180414)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: TheJulianJES <TheJulianJES@users.noreply.github.com>
This commit is contained in:
Stefan Agner
2026-08-28 19:57:31 +00:00
committed by Franck Nijhof
co-authored by Paulus Schoutsen TheJulianJES
parent d602736d12
commit 7ca74e3c04
3 changed files with 88 additions and 0 deletions
@@ -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",
@@ -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."
}
+84
View File
@@ -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,