home-assistant/core · error · ConfigEntryNotReady

bad_request

Error message

bad_request

What it means

Raised as ConfigEntryNotReady (translation key bad_request) when the setup call fails with exception.BadRequest. B2 returned HTTP 400, meaning the request itself was malformed or rejected (bad parameters, invalid realm, corrupted request); the raw error text is passed as the error_message placeholder.

Source

Thrown at homeassistant/components/backblaze_b2/__init__.py:77

            translation_key="invalid_credentials",
        ) from err
    except exception.RestrictedBucket as err:
        create_bucket_access_restricted_issue(hass, entry, err.bucket_name)
        raise ConfigEntryNotReady(
            translation_domain=DOMAIN,
            translation_key="restricted_bucket",
            translation_placeholders={
                "restricted_bucket_name": err.bucket_name,
            },
        ) from err
    except exception.NonExistentBucket as err:
        create_bucket_not_found_issue(hass, entry, entry.data[CONF_BUCKET])
        raise ConfigEntryNotReady(
            translation_domain=DOMAIN,
            translation_key="invalid_bucket_name",
        ) from err
    except exception.BadRequest as err:
        raise ConfigEntryNotReady(
            translation_domain=DOMAIN,
            translation_key="bad_request",
            translation_placeholders={"error_message": str(err)},
        ) from err
    except (
        exception.B2ConnectionError,
        exception.B2RequestTimeout,
        exception.ConnectionReset,
    ) as err:
        raise ConfigEntryNotReady(
            translation_domain=DOMAIN,
            translation_key="cannot_connect",
        ) from err
    except exception.MissingAccountData as err:
        raise ConfigEntryAuthFailed(
            translation_domain=DOMAIN,
            translation_key="invalid_auth",
        ) from err

View on GitHub (pinned to 58a3fdb3ea)

Solutions

  1. Read the error_message placeholder text for the exact B2 complaint
  2. Re-enter the config (reconfigure) to rebuild clean entry data
  3. Update the b2sdk package / HA core so SDK and API versions align
  4. Validate the bucket name against B2 naming rules (alphanumerics and dashes only)
Defensive patterns

Strategy: try-catch

Type guard

import b2sdk.v2.exception as b2exc

def is_bad_request(err: BaseException) -> bool:
    return isinstance(err, b2exc.BadRequest)

Try / catch

except exception.BadRequest as err:
    raise ConfigEntryNotReady(
        translation_domain=DOMAIN,
        translation_key="bad_request",
        translation_placeholders={"error_message": str(err)},
    ) from err

Prevention

When it happens

Trigger: authorize_account or get_bucket_by_name triggers a 400 from the B2 API — for example an invalid bucket name character, malformed key, or SDK/API version incompatibility producing a bad request.

Common situations: Unusual characters in bucket name, outdated b2sdk version against changed B2 API behavior, corrupted entry data after manual edits.

Related errors


AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14). Data as JSON: /api/errors/f44a62ca107f479d. Report an issue: GitHub.