Skip to content

Commit 8d1fded

Browse files
committed
fix: resolve CI test failures for Bedrock provider
- Update test assertion to match actual error message - Remove redundant comments flagged by linter - Update auto-generated provider documentation
1 parent a7a6191 commit 8d1fded

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

docs/docs/providers/safety/remote_bedrock.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ AWS Bedrock safety provider for content moderation using AWS's safety services.
1919
| `aws_access_key_id` | `str \| None` | No | | The AWS access key to use. Default use environment variable: AWS_ACCESS_KEY_ID |
2020
| `aws_secret_access_key` | `str \| None` | No | | The AWS secret access key to use. Default use environment variable: AWS_SECRET_ACCESS_KEY |
2121
| `aws_session_token` | `str \| None` | No | | The AWS session token to use. Default use environment variable: AWS_SESSION_TOKEN |
22-
| `region_name` | `str \| None` | No | us-east-2 | The default AWS Region to use, for example, us-west-1 or us-west-2.Default use environment variable: AWS_DEFAULT_REGION |
22+
| `region_name` | `str \| None` | No | | The default AWS Region to use, for example, us-west-1 or us-west-2.Default use environment variable: AWS_DEFAULT_REGION |
2323
| `profile_name` | `str \| None` | No | | The profile name that contains credentials to use.Default use environment variable: AWS_PROFILE |
2424
| `total_max_attempts` | `int \| None` | No | | An integer representing the maximum number of attempts that will be made for a single request, including the initial attempt. Default use environment variable: AWS_MAX_ATTEMPTS |
2525
| `retry_mode` | `str \| None` | No | | A string representing the type of retries Boto3 will perform.Default use environment variable: AWS_RETRY_MODE |

src/llama_stack/providers/remote/inference/bedrock/bedrock.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,15 @@ async def openai_chat_completion(
9595
result = await super().openai_chat_completion(params=params)
9696
logger.debug(f"Bedrock API returned: {type(result).__name__ if result is not None else 'None'}")
9797

98-
# Defensive check for unexpected None response
9998
if result is None:
100-
logger.error(f"OpenAI client returned None for model={params.model}, stream={params.stream}")
99+
logger.error(f"Bedrock OpenAI client returned None for model={params.model}, stream={params.stream}")
101100
raise RuntimeError(
102101
f"Bedrock API returned no response for model '{params.model}'. "
103102
"This may indicate the model is not supported or a network/API issue occurred."
104103
)
105104

106105
return result
107106
except AuthenticationError as e:
108-
# Extract detailed error message from the exception
109107
error_msg = str(e)
110108

111109
# Check if this is a token expiration error

tests/unit/providers/inference/test_bedrock_adapter.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@ def test_client_url_construction():
3131

3232

3333
def test_api_key_from_config():
34-
"""Test API key is stored as SecretStr in auth_credential"""
3534
config = BedrockConfig(api_key="config-key", region_name="us-east-1")
3635
adapter = BedrockInferenceAdapter(config=config)
37-
38-
# API key is stored in auth_credential field (SecretStr)
3936
assert adapter.config.auth_credential.get_secret_value() == "config-key"
4037

4138

@@ -75,7 +72,7 @@ async def test_authentication_error_handling():
7572
await adapter.openai_chat_completion(params=params)
7673

7774
assert "AWS Bedrock authentication failed" in str(exc_info.value)
78-
assert "Please check your API key" in str(exc_info.value)
75+
assert "Please verify your API key" in str(exc_info.value)
7976
finally:
8077
# Restore original method
8178
BedrockInferenceAdapter.__bases__[0].openai_chat_completion = original_method

0 commit comments

Comments
 (0)