{"record":{"id":"84b7d3df43d9161a","repo":"home-assistant/core","slug":"failed-during-func-name","errorCode":null,"errorMessage":"Failed during {func.__name__}","messagePattern":"Failed during (.+?)","errorType":"exception","errorClass":"BackupAgentError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/aws_s3/backup.py","lineNumber":49,"sourceCode":"# https://docs.aws.amazon.com/AmazonS3/latest/userguide/qfacts.html\n# We set the threshold to 20 MiB to avoid too many parts.\n# Note that each part is allocated in the memory.\nMULTIPART_MIN_PART_SIZE_BYTES = 20 * 2**20\n\n\ndef handle_boto_errors[T](\n    func: Callable[..., Coroutine[Any, Any, T]],\n) -> Callable[..., Coroutine[Any, Any, T]]:\n    \"\"\"Handle BotoCoreError exceptions by converting them to BackupAgentError.\"\"\"\n\n    @functools.wraps(func)\n    async def wrapper(*args: Any, **kwargs: Any) -> T:\n        \"\"\"Catch BotoCoreError and raise BackupAgentError.\"\"\"\n        try:\n            return await func(*args, **kwargs)\n        except BotoCoreError as err:\n            error_msg = f\"Failed during {func.__name__}\"\n            raise BackupAgentError(error_msg) 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.\"\"\"\n    entries: list[S3ConfigEntry] = hass.config_entries.async_loaded_entries(DOMAIN)\n    return [S3BackupAgent(hass, entry) for entry in entries]\n\n\n@callback\ndef async_register_backup_agents_listener(\n    hass: HomeAssistant,\n    *,\n    listener: Callable[[], None],\n    **kwargs: Any,","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/aws_s3/backup.py#L31-L67","documentation":"A decorator (handle_boto_errors) applied to S3 backup-agent methods that converts any BotoCoreError (superclass of ClientError, ConnectionError from botocore, EndpointConnectionError, etc.) into BackupAgentError with the message 'Failed during {func.__name__}'. The backup manager uses this to show a generic per-operation failure in the backup UI while the original cause stays chained in __cause__.","triggerScenarios":"Any decorated backup operation (e.g. downloading, deleting, listing metadata) performs a boto3 call that raises BotoCoreError: network failure to S3, credential/permission error, throttling, or param validation.","commonSituations":"Backup download or delete fails because the IAM key lost permissions after initial setup worked; endpoint unreachable during a long backup restore; S3 throttled the request.","solutions":["Check the chained exception in logs (BackupAgentError.__cause__) to see the real botocore error code.","Fix the underlying cause: IAM permissions (s3:GetObject/s3:DeleteObject), network reachability, or credentials.","Retry the backup operation once transient issues (throttling, brief outage) clear."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from homeassistant.components.backup import BackupAgentError\n\ntry:\n    await agent.async_download_backup(backup, path)\nexcept BackupAgentError as err:\n    root = err.__cause__  # original BotoCoreError carries the actionable code\n    handle_botocore(root)","preventionTips":["Always inspect __cause__ — the wrapper message intentionally hides the detail.","Keep IAM permissions for download/delete aligned with upload permissions.","Retry once for transient botocore errors (throttle, connection) before alerting."],"tags":["home-assistant","aws","s3","backup","botocore"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}