{"record":{"id":"b637a5277e8f8fa9","repo":"openai/openai-python","slug":"the-bedrock-aws-region-must-not-be-empty","errorCode":null,"errorMessage":"The Bedrock AWS `region` must not be empty.","messagePattern":"The Bedrock AWS `region` must not be empty\\.","errorType":"exception","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"src/openai/providers/bedrock.py","lineNumber":403,"sourceCode":"    endpoint: BedrockEndpoint | None = None,\n    region: str | None = None,\n    base_url: str | httpx2.URL | None | NotGiven = NOT_GIVEN,\n    api_key: str | None | NotGiven = NOT_GIVEN,\n    token_provider: BedrockTokenProvider | None = None,\n    access_key_id: str | None = None,\n    secret_access_key: str | None = None,\n    session_token: str | None = None,\n    profile: str | None = None,\n    credential_provider: AwsCredentialsProvider | None = None,\n) -> _Provider:\n    \"\"\"Configure the standard OpenAI client for Amazon Bedrock Mantle or Runtime.\"\"\"\n\n    if endpoint is not None and endpoint not in {\"mantle\", \"runtime\"}:\n        raise OpenAIError(\"The Bedrock `endpoint` must be either `mantle` or `runtime`.\")\n\n    normalized_region = _normalize_optional_string(region)\n    if region is not None and normalized_region is None:\n        raise OpenAIError(\"The Bedrock AWS `region` must not be empty.\")\n    _validate_bedrock_region(normalized_region)\n\n    region_source: Literal[\"explicit\", \"environment\"] | None = \"explicit\" if normalized_region is not None else None\n\n    configured_base_url: httpx2.URL | None\n    if isinstance(base_url, NotGiven):\n        environment_base_url = _normalize_optional_string(os.environ.get(\"AWS_BEDROCK_BASE_URL\"))\n        configured_base_url = _normalize_base_url(environment_base_url) if environment_base_url else None\n    elif base_url is None:\n        configured_base_url = None\n    else:\n        if isinstance(base_url, str) and not base_url.strip():\n            raise OpenAIError(\"The Bedrock `base_url` must not be empty.\")\n        configured_base_url = _normalize_base_url(base_url)\n\n    canonical_endpoint = (\n        _parse_bedrock_endpoint_hostname(configured_base_url.host) if configured_base_url is not None else None\n    )","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/providers/bedrock.py#L385-L421","documentation":"A `region` argument was supplied to `bedrock()` but it normalizes to an empty value (empty string or whitespace-only). Because region is how the SDK builds the AWS endpoint host, an empty-but-present region is rejected rather than silently used.","triggerScenarios":"Calling bedrock(region='') or bedrock(region='   '); commonly happens when region is read from a config/env variable that is defined but blank.","commonSituations":"region = os.environ.get('AWS_REGION', '') passed straight through, or a YAML/TOML config with `region = \"\"`.","solutions":["Pass a real region like 'us-east-1', or pass None to use environment detection","Trim/validate config values before forwarding them to bedrock()"],"exampleFix":"# before\nbedrock(region=os.environ.get('AWS_REGION', ''))\n# after\nbedrock(region=os.environ.get('AWS_REGION') or None)","handlingStrategy":"validation","validationCode":"region = (region or '').strip() or None\nbedrock(region=region)","typeGuard":"def is_nonempty_str(v: object) -> bool:\n    return isinstance(v, str) and bool(v.strip())","tryCatchPattern":null,"preventionTips":["Normalize env-derived config with `x or None`","Strip config values at load time"],"tags":["bedrock","region","validation","config"],"backgroundTag":"empty-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}