BerriAI/litellm · error · ValueError

Invalid AWS region format

Error message

Invalid AWS region format: {aws_region_name!r}. Region names must contain only lowercase letters, digits, and hyphens.

What it means

Validation failure in _validate_aws_region_name: the resolved AWS region name contains characters other than lowercase letters, digits, and hyphens. The misconfigured region (from env vars, params, or defaults) is the input at fault.

Solutions

  1. Use a valid AWS region name (lowercase letters, digits, hyphens, e.g. us-east-1).
  2. Check aws_region_name / AWS_REGION_NAME for typos or uppercase characters.
  3. Remove whitespace or invalid characters from the region setting.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/bedrock/base_aws_llm.py:611 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/59eb24f9e593dc2a. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/bedrock/base_aws_llm.py:611

                    aws_region_name = configured_region
                else:
                    aws_region_name = "us-west-2"
            except Exception:
                aws_region_name = "us-west-2"

        self._validate_aws_region_name(aws_region_name)
        return aws_region_name

    @staticmethod
    def _validate_aws_region_name(aws_region_name: str | None) -> None:
        """
        Validate that an AWS region name conforms to the expected format
        (lowercase alphanumerics and hyphens). Raises ValueError otherwise.
        """
        if aws_region_name is None:
            return
        if not isinstance(aws_region_name, str) or not _VALID_AWS_REGION_PATTERN.match(aws_region_name):
            raise ValueError(
                f"Invalid AWS region format: {aws_region_name!r}. "
                "Region names must contain only lowercase letters, digits, and hyphens."
            )

    @staticmethod
    def _parse_sts_region_from_endpoint(
        aws_sts_endpoint: str | None,
    ) -> str | None:
        """Extract region from sts.{region}.amazonaws.com or vpce-x.sts.{region}.vpce.amazonaws.com."""
        if not aws_sts_endpoint:
            return None
        host: Final = urllib.parse.urlparse(aws_sts_endpoint).hostname or ""
        match: Final = _STS_REGION_FROM_ENDPOINT_PATTERN.search(host)
        return match.group(1) if match else None

    @staticmethod
    def _resolve_sts_region(aws_sts_endpoint: str | None = None) -> str | None:
        """STS signing region: parsed from aws_sts_endpoint else AWS_REGION / AWS_DEFAULT_REGION."""

View on GitHub (pinned to 77b7c6c40c)