{"record":{"id":"9ffa47e0deb0767b","repo":"home-assistant/core","slug":"restricted-bucket","errorCode":null,"errorMessage":"restricted_bucket","messagePattern":"restricted_bucket","errorType":"exception","errorClass":"ConfigEntryNotReady","httpStatus":null,"severity":"error","filePath":"homeassistant/components/backblaze_b2/__init__.py","lineNumber":63,"sourceCode":"        b2sdk operations are blocking.\n        \"\"\"\n        b2_api.authorize_account(\n            BACKBLAZE_REALM,\n            entry.data[CONF_KEY_ID],\n            entry.data[CONF_APPLICATION_KEY],\n        )\n        return b2_api.get_bucket_by_name(entry.data[CONF_BUCKET])\n\n    try:\n        bucket = await hass.async_add_executor_job(_authorize_and_get_bucket_sync)\n    except exception.Unauthorized as err:\n        raise ConfigEntryAuthFailed(\n            translation_domain=DOMAIN,\n            translation_key=\"invalid_credentials\",\n        ) from err\n    except exception.RestrictedBucket as err:\n        create_bucket_access_restricted_issue(hass, entry, err.bucket_name)\n        raise ConfigEntryNotReady(\n            translation_domain=DOMAIN,\n            translation_key=\"restricted_bucket\",\n            translation_placeholders={\n                \"restricted_bucket_name\": err.bucket_name,\n            },\n        ) from err\n    except exception.NonExistentBucket as err:\n        create_bucket_not_found_issue(hass, entry, entry.data[CONF_BUCKET])\n        raise ConfigEntryNotReady(\n            translation_domain=DOMAIN,\n            translation_key=\"invalid_bucket_name\",\n        ) from err\n    except exception.BadRequest as err:\n        raise ConfigEntryNotReady(\n            translation_domain=DOMAIN,\n            translation_key=\"bad_request\",\n            translation_placeholders={\"error_message\": str(err)},\n        ) from err","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/backblaze_b2/__init__.py#L45-L81","documentation":"Raised as ConfigEntryNotReady (translation key restricted_bucket) when authorize/get_bucket fails with exception.RestrictedBucket. The credentials are valid but the application key is restricted to a different bucket (or no buckets), so get_bucket_by_name for the configured bucket cannot authorize it. HA also creates a repair issue naming the bucket.","triggerScenarios":"An application key limited via bucketId/bucketName restrictions is used with a CONF_BUCKET entry whose bucket is outside the key's allowed set; b2sdk raises RestrictedBucket with err.bucket_name.","commonSituations":"User created an app key scoped to bucket A but configured the integration for bucket B; key created with 'Allow access to buckets' left unset; bucket deleted and recreated (new bucketId not covered by the key).","solutions":["Either reconfigure the integration to use the bucket allowed by the application key, or create a new application key that allows the configured bucket","If the bucket was recreated, generate a fresh app key for the new bucket and update credentials","Dismiss the repair issue after fixing the mismatch"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# before setup: confirm the key can list the target bucket\nbuckets = [b.name for b in b2_api.list_buckets()]\nif entry.data[CONF_BUCKET] not in buckets:\n    # restricted or missing: fix key scope or bucket choice now","typeGuard":"import b2sdk.v2.exception as b2exc\n\ndef is_restricted_bucket(err: BaseException) -> bool:\n    return isinstance(err, b2exc.RestrictedBucket)","tryCatchPattern":"except exception.RestrictedBucket as err:\n    create_bucket_access_restricted_issue(hass, entry, err.bucket_name)\n    raise ConfigEntryNotReady(translation_domain=DOMAIN, translation_key=\"restricted_bucket\", ...) from err","preventionTips":["When creating an app key, explicitly allow access to the bucket you will configure","After recreating a bucket, reissue the app key (bucketId changes)","Read the repair issue — it names the bucket the key actually allows"],"tags":["backblaze","b2","authorization","config-entry"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}