{"record":{"id":"39d6a681f5ea0bc2","repo":"home-assistant/core","slug":"invalid-bucket-name","errorCode":"invalid_bucket_name","errorMessage":"Invalid bucket name","messagePattern":"Invalid bucket name","errorType":"exception","errorClass":"ConfigEntryError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/aws_s3/__init__.py","lineNumber":49,"sourceCode":"    data = cast(dict, entry.data)\n    try:\n        session = AioSession()\n        # pylint: disable-next=unnecessary-dunder-call\n        client = await session.create_client(\n            \"s3\",\n            endpoint_url=data.get(CONF_ENDPOINT_URL),\n            aws_secret_access_key=data[CONF_SECRET_ACCESS_KEY],\n            aws_access_key_id=data[CONF_ACCESS_KEY_ID],\n        ).__aenter__()\n        await client.head_bucket(Bucket=data[CONF_BUCKET])\n    except ClientError as err:\n        raise ConfigEntryError(\n            translation_domain=DOMAIN,\n            translation_key=\"invalid_credentials\",\n        ) from err\n    except ParamValidationError as err:\n        if \"Invalid bucket name\" in str(err):\n            raise ConfigEntryError(\n                translation_domain=DOMAIN,\n                translation_key=\"invalid_bucket_name\",\n            ) from err\n    except ValueError as err:\n        raise ConfigEntryError(\n            translation_domain=DOMAIN,\n            translation_key=\"invalid_endpoint_url\",\n        ) from err\n    except ConnectionError as err:\n        raise ConfigEntryNotReady(\n            translation_domain=DOMAIN,\n            translation_key=\"cannot_connect\",\n        ) from err\n\n    coordinator = S3DataUpdateCoordinator(\n        hass,\n        entry=entry,\n        client=client,","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/aws_s3/__init__.py#L31-L67","documentation":"Raised as ConfigEntryError (translation_key invalid_bucket_name) by aws_s3 when head_bucket raises botocore ParamValidationError whose string contains 'Invalid bucket name' — the configured bucket string violates S3 naming rules, so boto3 refuses to even send the request.","triggerScenarios":"data[CONF_BUCKET] contains characters botocore rejects: uppercase letters, underscores, spaces, leading/trailing slashes, 's3://' scheme prefix, or a full URL pasted instead of the bare bucket name.","commonSituations":"User pasted the S3 URI (s3://my-bucket) or ARN instead of the bucket name; bucket name typo'd with uppercase or underscore; endpoint-style config copied from another tool.","solutions":["Set the bucket field to the bare bucket name only (lowercase, no s3://, no path, no ARN), e.g. 'my-homeassistant-backups'.","Check S3 naming rules: 3-63 chars, lowercase letters, numbers, dots, and hyphens only; must not look like an IP.","Note: ParamValidationError messages not matching 'Invalid bucket name' fall through unhandled — if you see a different ParamValidationError, check for empty/None bucket config."],"exampleFix":"# before\nbucket: s3://My-Backups\n# after\nbucket: my-backups\n","handlingStrategy":"validation","validationCode":"import re\n\nBUCKET_RE = re.compile(r\"^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$\")\n\ndef valid_bucket_name(name: str) -> bool:\n    return bool(name) and bool(BUCKET_RE.fullmatch(name)) and \"..\" not in name and not re.fullmatch(r\"[\\d.]+\", name)\n","typeGuard":null,"tryCatchPattern":"from botocore.exceptions import ParamValidationError\n\ntry:\n    await client.head_bucket(Bucket=bucket)\nexcept ParamValidationError as err:\n    if \"Invalid bucket name\" in str(err):\n        fix_bucket_field()  # config error, not transient — do not retry","preventionTips":["Store only the bare bucket name; strip s3:// and paths in UI code before saving.","Validate bucket names client-side with the S3 naming rules regex before setup.","Beware the fall-through: ParamValidationError without 'Invalid bucket name' is re-raised uncaught."],"tags":["home-assistant","aws","s3","validation","configuration"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}