{"record":{"id":"65bdd3f0082d35f8","repo":"home-assistant/core","slug":"failed-during-func-name-err","errorCode":null,"errorMessage":"Failed during {func.__name__}: {err}","messagePattern":"Failed during (.+?): (.+?)","errorType":"exception","errorClass":"BackupAgentError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/backblaze_b2/backup.py","lineNumber":116,"sourceCode":"    Uses the associated backup file to set the size.\n    \"\"\"\n    metadata = metadata_content[\"backup_metadata\"]\n    metadata[\"size\"] = backup_file.size\n    return AgentBackup.from_dict(metadata)\n\n\ndef handle_b2_errors[T](\n    func: Callable[..., Coroutine[Any, Any, T]],\n) -> Callable[..., Coroutine[Any, Any, T]]:\n    \"\"\"Handle B2Errors by converting them to BackupAgentError.\"\"\"\n\n    @functools.wraps(func)\n    async def wrapper(*args: Any, **kwargs: Any) -> T:\n        \"\"\"Catch B2Error and raise BackupAgentError.\"\"\"\n        try:\n            return await func(*args, **kwargs)\n        except B2Error as err:\n            raise BackupAgentError(f\"Failed during {func.__name__}: {err}\") from err\n\n    return wrapper\n\n\nasync def async_get_backup_agents(\n    hass: HomeAssistant,\n) -> list[BackupAgent]:\n    \"\"\"Return a list of backup agents for all configured Backblaze B2 entries.\"\"\"\n    entries: list[BackblazeConfigEntry] = hass.config_entries.async_loaded_entries(\n        DOMAIN\n    )\n    return [BackblazeBackupAgent(hass, entry) for entry in entries]\n\n\n@callback\ndef async_register_backup_agents_listener(\n    hass: HomeAssistant,\n    *,","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/backblaze_b2/backup.py#L98-L134","documentation":"BackupAgentError raised by the handle_b2_errors decorator when any b2sdk B2Error escapes a decorated backup method. The message embeds the failing method name and the B2 error text, and the original B2Error is chained as __cause__ for diagnosis.","triggerScenarios":"Any B2Error during download/upload/delete/list: BadRequest, FileNotPresent, Unauthorized (SAS-like auth failures with B2), B2ConnectionError, ServiceUnavailable, CapExceededExceededB2Account (storage cap) during upload.","commonSituations":"Storage cap exceeded mid-backup, file already deleted (FileNotPresent) on delete/download, key capabilities insufficient for writeFiles, network errors during large uploads.","solutions":["Read the embedded B2 error text (and __cause__) to identify the operation and failure reason","Cap exceeded: free space or raise the B2 storage cap, then retry the backup","Auth errors: reauth the integration and retry","Transient errors: rerun the backup; the manager reports failure and can be retriggered"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import b2sdk.v2.exception as b2exc\n\ndef is_b2_error(err: BaseException) -> bool:\n    return isinstance(err, b2exc.B2Error)","tryCatchPattern":"from homeassistant.components.backup.exceptions import BackupAgentError\ntry:\n    await agent.async_upload_backup(open_stream=open_stream, backup=backup, on_progress=cb)\nexcept BackupAgentError as err:\n    cause = err.__cause__  # original B2Error — branch on its type","preventionTips":["Check storage cap and key capabilities before large uploads","Handle BackupAgentError and inspect __cause__ (B2Error text is embedded in the message)","Retry transient B2Errors (connection/service unavailable) via the backup manager"],"tags":["backblaze","b2","backup","wrapper"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}