diff --git a/homeassistant/components/backup/http.py b/homeassistant/components/backup/http.py index bd70b471721c..ece02a6c2157 100644 --- a/homeassistant/components/backup/http.py +++ b/homeassistant/components/backup/http.py @@ -13,7 +13,6 @@ from multidict import istr from homeassistant.components.http import KEY_HASS, HomeAssistantView, require_admin from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import HomeAssistantError -from homeassistant.helpers import frame from homeassistant.util import slugify from homeassistant.util.async_iterator import ( AsyncIteratorReader, @@ -68,16 +67,6 @@ class DownloadBackupView(HomeAssistantView): except BackupNotFound: return Response(status=HTTPStatus.NOT_FOUND) - # Check for None to be backwards compatible with the old BackupAgent API, - # this can be removed in HA Core 2025.10 - if not backup: - frame.report_usage( - "returns None from BackupAgent.async_get_backup", - breaks_in_ha_version="2025.10", - integration_domain=agent_id.partition(".")[0], - ) - return Response(status=HTTPStatus.NOT_FOUND) - headers = { CONTENT_DISPOSITION: f"attachment; filename={slugify(backup.name)}.tar", CONTENT_TYPE: "application/x-tar", diff --git a/homeassistant/components/backup/manager.py b/homeassistant/components/backup/manager.py index 1f579d7a1adb..865c2f76c3dd 100644 --- a/homeassistant/components/backup/manager.py +++ b/homeassistant/components/backup/manager.py @@ -24,7 +24,6 @@ from homeassistant.backup_restore import RESTORE_BACKUP_FILE, RESTORE_BACKUP_RES from homeassistant.const import __version__ as HAVERSION from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import ( - frame, instance_id, integration_platform, issue_registry as ir, @@ -821,15 +820,6 @@ class BackupManager: continue if isinstance(result, BaseException): raise result # unexpected error - # Check for None to be backwards compatible with the old BackupAgent API, - # this can be removed in HA Core 2025.10 - if not result: - frame.report_usage( - "returns None from BackupAgent.async_get_backup", - breaks_in_ha_version="2025.10", - integration_domain=agent_id.partition(".")[0], - ) - continue if backup is None: if known_backup := self.known_backups.get(backup_id): failed_addons = known_backup.failed_addons @@ -1467,22 +1457,11 @@ class BackupManager: """Initiate restoring a backup.""" agent = self.backup_agents[agent_id] try: - backup = await agent.async_get_backup(backup_id) + await agent.async_get_backup(backup_id) except BackupNotFound as err: raise BackupManagerError( f"Backup {backup_id} not found in agent {agent_id}" ) from err - # Check for None to be backwards compatible with the old BackupAgent API, - # this can be removed in HA Core 2025.10 - if not backup: - frame.report_usage( - "returns None from BackupAgent.async_get_backup", - breaks_in_ha_version="2025.10", - integration_domain=agent_id.partition(".")[0], - ) - raise BackupManagerError( - f"Backup {backup_id} not found in agent {agent_id}" - ) async def open_backup() -> AsyncIterator[bytes]: return await agent.async_download_backup(backup_id) @@ -1637,22 +1616,11 @@ class BackupManager: except KeyError as err: raise BackupManagerError(f"Invalid agent selected: {agent_id}") from err try: - backup = await agent.async_get_backup(backup_id) + await agent.async_get_backup(backup_id) except BackupNotFound as err: raise BackupManagerError( f"Backup {backup_id} not found in agent {agent_id}" ) from err - # Check for None to be backwards compatible with the old BackupAgent API, - # this can be removed in HA Core 2025.10 - if not backup: - frame.report_usage( - "returns None from BackupAgent.async_get_backup", - breaks_in_ha_version="2025.10", - integration_domain=agent_id.partition(".")[0], - ) - raise BackupManagerError( - f"Backup {backup_id} not found in agent {agent_id}" - ) reader: IO[bytes] if agent_id in self.local_backup_agents: local_agent = self.local_backup_agents[agent_id] diff --git a/tests/components/backup/snapshots/test_websocket.ambr b/tests/components/backup/snapshots/test_websocket.ambr index 874360fb3fd3..635635615a6e 100644 --- a/tests/components/backup/snapshots/test_websocket.ambr +++ b/tests/components/backup/snapshots/test_websocket.ambr @@ -250,17 +250,6 @@ 'type': 'result', }) # --- -# name: test_can_decrypt_on_download_get_backup_returns_none - dict({ - 'error': dict({ - 'code': 'home_assistant_error', - 'message': 'Backup abc123 not found in agent test.remote', - }), - 'id': 1, - 'success': False, - 'type': 'result', - }) -# --- # name: test_can_decrypt_on_download_with_agent_error[BackupAgentError] dict({ 'error': dict({ @@ -5723,20 +5712,6 @@ 'type': 'result', }) # --- -# name: test_details_get_backup_returns_none - dict({ - 'id': 1, - 'result': dict({ - 'agent_error_translations': dict({ - }), - 'agent_errors': dict({ - }), - 'backup': None, - }), - 'success': True, - 'type': 'result', - }) -# --- # name: test_details_with_errors[BackupAgentUnreachableError] dict({ 'id': 1, @@ -6876,17 +6851,6 @@ # name: test_restore_remote_agent[remote_agents1-backups1].1 1 # --- -# name: test_restore_remote_agent_get_backup_returns_none - dict({ - 'error': dict({ - 'code': 'home_assistant_error', - 'message': 'Backup abc123 not found in agent test.remote', - }), - 'id': 1, - 'success': False, - 'type': 'result', - }) -# --- # name: test_restore_wrong_password dict({ 'error': dict({ diff --git a/tests/components/backup/test_http.py b/tests/components/backup/test_http.py index a2128616dc4f..6928308559e0 100644 --- a/tests/components/backup/test_http.py +++ b/tests/components/backup/test_http.py @@ -265,26 +265,6 @@ async def test_downloading_backup_not_found( assert resp.status == 404 -async def test_downloading_backup_not_found_get_backup_returns_none( - hass: HomeAssistant, - hass_client: ClientSessionGenerator, - caplog: pytest.LogCaptureFixture, -) -> None: - """Test downloading a backup file that does not exist.""" - mock_agents = await setup_backup_integration(hass, remote_agents=["test.test"]) - mock_agents["test.test"].async_get_backup.return_value = None - mock_agents["test.test"].async_get_backup.side_effect = None - - client = await hass_client() - - resp = await client.get("/api/backup/download/abc123?agent_id=test.test") - assert resp.status == 404 - assert ( - "Detected that integration 'test' returns None from" - " BackupAgent.async_get_backup." in caplog.text - ) - - async def test_downloading_as_non_admin( hass: HomeAssistant, hass_client: ClientSessionGenerator, diff --git a/tests/components/backup/test_websocket.py b/tests/components/backup/test_websocket.py index fd74bcc9de31..f4201f4bf54a 100644 --- a/tests/components/backup/test_websocket.py +++ b/tests/components/backup/test_websocket.py @@ -278,31 +278,6 @@ async def test_details_with_errors( assert await client.receive_json() == snapshot -async def test_details_get_backup_returns_none( - hass: HomeAssistant, - hass_ws_client: WebSocketGenerator, - caplog: pytest.LogCaptureFixture, - snapshot: SnapshotAssertion, -) -> None: - """Test getting backup info when the agent returns None from get_backup.""" - mock_agents = await setup_backup_integration(hass, remote_agents=["test.remote"]) - mock_agents["test.remote"].async_get_backup.return_value = None - mock_agents["test.remote"].async_get_backup.side_effect = None - - client = await hass_ws_client(hass) - await hass.async_block_till_done() - - with patch("pathlib.Path.exists", return_value=True): - await client.send_json_auto_id( - {"type": "backup/details", "backup_id": "abc123"} - ) - assert await client.receive_json() == snapshot - assert ( - "Detected that integration 'test' returns None from" - " BackupAgent.async_get_backup." in caplog.text - ) - - @pytest.mark.parametrize( ("remote_agents", "backups"), [ @@ -821,36 +796,6 @@ async def test_restore_remote_agent( assert len(restart_calls) == snapshot -async def test_restore_remote_agent_get_backup_returns_none( - hass: HomeAssistant, - hass_ws_client: WebSocketGenerator, - caplog: pytest.LogCaptureFixture, - snapshot: SnapshotAssertion, -) -> None: - """Test calling the restore command when the agent returns None from get_backup.""" - mock_agents = await setup_backup_integration(hass, remote_agents=["test.remote"]) - mock_agents["test.remote"].async_get_backup.return_value = None - mock_agents["test.remote"].async_get_backup.side_effect = None - restart_calls = async_mock_service(hass, "homeassistant", "restart") - - client = await hass_ws_client(hass) - await hass.async_block_till_done() - - await client.send_json_auto_id( - { - "type": "backup/restore", - "backup_id": "abc123", - "agent_id": "test.remote", - } - ) - assert await client.receive_json() == snapshot - assert len(restart_calls) == 0 - assert ( - "Detected that integration 'test' returns None from" - " BackupAgent.async_get_backup." in caplog.text - ) - - async def test_restore_wrong_password( hass: HomeAssistant, hass_ws_client: WebSocketGenerator, @@ -4385,32 +4330,3 @@ async def test_can_decrypt_on_download_with_agent_error( } ) assert await client.receive_json() == snapshot - - -@pytest.mark.usefixtures("mock_backups") -async def test_can_decrypt_on_download_get_backup_returns_none( - hass: HomeAssistant, - hass_ws_client: WebSocketGenerator, - caplog: pytest.LogCaptureFixture, - snapshot: SnapshotAssertion, -) -> None: - """Test can decrypt on download when the agent returns None from get_backup.""" - - mock_agents = await setup_backup_integration(hass, remote_agents=["test.remote"]) - mock_agents["test.remote"].async_get_backup.return_value = None - mock_agents["test.remote"].async_get_backup.side_effect = None - - client = await hass_ws_client(hass) - await client.send_json_auto_id( - { - "type": "backup/can_decrypt_on_download", - "backup_id": TEST_BACKUP_ABC123.backup_id, - "agent_id": "test.remote", - "password": "hunter2", - } - ) - assert await client.receive_json() == snapshot - assert ( - "Detected that integration 'test' returns None from" - " BackupAgent.async_get_backup." in caplog.text - )