{"record":{"id":"ebce437d5db2edcb","repo":"openai/openai-python","slug":"the-bedrock-base-url-must-not-be-empty","errorCode":null,"errorMessage":"The Bedrock `base_url` must not be empty.","messagePattern":"The Bedrock `base_url` must not be empty\\.","errorType":"exception","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"src/openai/providers/bedrock.py","lineNumber":416,"sourceCode":"    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    )\n    resolved_endpoint: BedrockEndpoint = endpoint or (\n        canonical_endpoint[0] if canonical_endpoint is not None else \"mantle\"\n    )\n\n    normalized_profile = _normalize_optional_string(profile)\n    if profile is not None and normalized_profile is None:\n        raise OpenAIError(\"The Bedrock AWS `profile` must not be empty.\")\n\n    if (access_key_id is None) != (secret_access_key is None) or (session_token is not None and access_key_id is None):\n        raise OpenAIError(\n            \"Static AWS credentials require both `access_key_id` and `secret_access_key`. \"\n            \"A `session_token` may only be used with both.\"\n        )","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/providers/bedrock.py#L398-L434","documentation":"A `base_url` argument was provided to `bedrock()` as a string containing only whitespace. Since base_url overrides endpoint construction, an explicitly empty value is treated as a configuration mistake and rejected.","triggerScenarios":"Calling bedrock(base_url='') or base_url='   '; typically when the value comes from a template variable or env var that resolved to blank.","commonSituations":"EMPTY_AWS_BEDROCK_BASE_URL-style env plumbing, or Docker/Kubernetes configs where a variable is set but empty.","solutions":["Pass a real URL or None (or NotGiven) so environment/AWS defaults apply","Guard env-derived URLs: `base_url = os.environ.get('AWS_BEDROCK_BASE_URL') or None`"],"exampleFix":"# before\nbedrock(base_url=os.environ.get('AWS_BEDROCK_BASE_URL', ''))\n# after\nbedrock(base_url=os.environ.get('AWS_BEDROCK_BASE_URL') or None)","handlingStrategy":"validation","validationCode":"base_url = os.environ.get('AWS_BEDROCK_BASE_URL') or None\nbedrock(base_url=base_url)","typeGuard":"def is_valid_base_url(v: object) -> bool:\n    return v is None or (isinstance(v, str) and bool(v.strip()))","tryCatchPattern":null,"preventionTips":["Never default env lookups to ''","Validate URLs in config loaders"],"tags":["bedrock","base-url","validation","config"],"backgroundTag":"empty-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}