{"record":{"id":"b17f15795e9767ac","repo":"openai/openai-python","slug":"static-aws-credentials-require-both-access-key-id","errorCode":null,"errorMessage":"Static AWS credentials require both `access_key_id` and `secret_access_key`. A `session_token` may only be used with both.","messagePattern":"Static AWS credentials require both `access_key_id` and `secret_access_key`\\. A `session_token` may only be used with both\\.","errorType":"exception","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"src/openai/providers/bedrock.py","lineNumber":431,"sourceCode":"        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\n    aws_modes = sum(\n        (\n            access_key_id is not None,","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/providers/bedrock.py#L413-L449","documentation":"Static AWS credential arguments must be complete: `access_key_id` and `secret_access_key` are a pair, and `session_token` is only valid when both are present. Supplying only one of the pair, or a session token without the key pair, raises this OpenAIError.","triggerScenarios":"bedrock(secret_access_key='...') without access_key_id; bedrock(access_key_id='...') without secret_access_key; bedrock(session_token='...') with no static keys.","commonSituations":"Copy-pasting only part of a credential set, or conditionally passing keys (e.g. secret set in one env but key unset in another) and forwarding both variables blindly.","solutions":["Provide both access_key_id and secret_access_key together, plus session_token only if using temporary credentials","Drop session_token if you only have long-lived keys","If using a profile or token provider instead, remove the partial static keys entirely"],"exampleFix":"# before\nbedrock(access_key_id=ak, session_token=st)\n# after\nbedrock(access_key_id=ak, secret_access_key=sk, session_token=st)","handlingStrategy":"validation","validationCode":"if (access_key_id is None) != (secret_access_key is None) or (session_token and not access_key_id):\n    raise ValueError('incomplete static AWS credentials')","typeGuard":"def has_complete_static_creds(ak: str | None, sk: str | None, st: str | None) -> bool:\n    return (ak is None) == (sk is None) and (st is None or ak is not None)","tryCatchPattern":null,"preventionTips":["Set all three env vars together or none","Validate credential tuples in config loading"],"tags":["bedrock","aws-credentials","validation"],"backgroundTag":"incomplete-credential-pair","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}