{"record":{"id":"3b5231c622c321a1","repo":"openai/openai-python","slug":"the-bedrock-aws-profile-must-not-be-empty","errorCode":null,"errorMessage":"The Bedrock AWS `profile` must not be empty.","messagePattern":"The Bedrock AWS `profile` must not be empty\\.","errorType":"exception","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"src/openai/providers/bedrock.py","lineNumber":428,"sourceCode":"        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        )\n    if access_key_id is not None and (not access_key_id.strip() or not cast(str, secret_access_key).strip()):\n        raise OpenAIError(\"Static AWS credentials require non-empty `access_key_id` and `secret_access_key` values.\")\n    if session_token is not None and not session_token.strip():\n        raise OpenAIError(\"A static AWS `session_token` must not be empty when provided.\")\n\n    explicit_api_key = not isinstance(api_key, NotGiven) and api_key is not None\n    if explicit_api_key and (not isinstance(api_key, str) or not api_key.strip()):\n        raise OpenAIError(\"The Bedrock bearer credential must not be empty.\")\n    if explicit_api_key and token_provider is not None:\n        raise OpenAIError(\"The `api_key` and `token_provider` options are mutually exclusive. Configure only one.\")\n\n    explicit_bearer = explicit_api_key or token_provider is not None","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/providers/bedrock.py#L410-L446","documentation":"A `profile` argument was supplied to `bedrock()` but it is empty or whitespace-only. The profile name selects a shared-credentials entry, so an explicitly empty string is rejected as a misconfiguration.","triggerScenarios":"Calling bedrock(profile='') or profile='  ', often from a blank AWS_PROFILE-style setting forwarded into the provider.","commonSituations":"profile = os.environ.get('AWS_PROFILE', '') forwarded unconditionally, or CI config with an empty profile key.","solutions":["Pass a real profile name or None to use the default credential chain","Normalize env-derived values: `os.environ.get('AWS_PROFILE') or None`"],"exampleFix":"# before\nbedrock(profile=os.environ.get('AWS_PROFILE', ''))\n# after\nbedrock(profile=os.environ.get('AWS_PROFILE') or None)","handlingStrategy":"validation","validationCode":"profile = os.environ.get('AWS_PROFILE') or None\nbedrock(profile=profile)","typeGuard":"def is_nonempty_profile(v: object) -> bool:\n    return v is None or (isinstance(v, str) and bool(v.strip()))","tryCatchPattern":null,"preventionTips":["Treat blank profile as 'use default chain' via None","Centralize AWS config normalization"],"tags":["bedrock","profile","aws-credentials","validation"],"backgroundTag":"empty-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}