Harmonize folder and add-on backup error handling (#5885)

* Harmonize folder and add-on backup error handling

Align add-on and folder backup error handling in that in both cases
errors are recorded on the respective backup Jobs, but not raised to
the caller. This allows the backup to complete successfully even if
some add-ons or folders fail to back up.

Along with this, also record errors in the per-add-on and per-folder
backup jobs, as well as the add-on and folder root job.

And finally, align the exception handling to only catch expected
exceptions for add-ons too.

* Fix pytest
This commit is contained in:
Stefan Agner
2025-05-15 10:14:35 +02:00
committed by GitHub
parent cbf4b4e27e
commit d0d11db7b1
5 changed files with 87 additions and 42 deletions

View File

@@ -372,7 +372,9 @@ async def test_api_backup_errors(
assert coresys.jobs.jobs == []
with patch.object(Addon, "backup", side_effect=AddonsError("Backup error")):
with patch.object(
Addon, "backup", side_effect=(err := AddonsError("Backup error"))
):
resp = await api_client.post(
f"/backups/new/{backup_type}",
json={"name": f"{backup_type} backup"} | options,
@@ -397,7 +399,7 @@ async def test_api_backup_errors(
assert job["child_jobs"][1]["child_jobs"][0]["errors"] == [
{
"type": "BackupError",
"message": "Can't create backup for local_ssh",
"message": str(err),
"stage": None,
}
]