Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/strands/models/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,13 +875,13 @@ def _stream(
add_exception_note(e, f"└ Model id: {self.config.get('model_id')}")

if (
e.response["Error"]["Code"] == "AccessDeniedException"
and "You don't have access to the model" in error_message
e.response["Error"]["Code"] == "ValidationException"
and "The provided model identifier is invalid" in error_message
):
add_exception_note(
e,
"└ For more information see "
"https://strandsagents.com/latest/user-guide/concepts/model-providers/amazon-bedrock/#model-access-issue",
"https://strandsagents.com/docs/user-guide/concepts/model-providers/amazon-bedrock/#model-identifier-is-invalid",
)

if (
Expand All @@ -891,7 +891,7 @@ def _stream(
add_exception_note(
e,
"└ For more information see "
"https://strandsagents.com/latest/user-guide/concepts/model-providers/amazon-bedrock/#on-demand-throughput-isnt-supported",
"https://strandsagents.com/docs/user-guide/concepts/model-providers/amazon-bedrock/#on-demand-throughput-isnt-supported",
)

raise e
Expand Down
14 changes: 7 additions & 7 deletions tests/strands/models/test_bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1479,14 +1479,14 @@ async def test_no_add_note_when_not_available(bedrock_client, model, alist, mess

@pytest.mark.skipif(sys.version_info < (3, 11), reason="This test requires Python 3.11 or higher (need add_note)")
@pytest.mark.asyncio
async def test_add_note_on_access_denied_exception(bedrock_client, model, alist, messages):
"""Test that add_note adds documentation link for AccessDeniedException."""
async def test_add_note_on_validation_exception_identifier(bedrock_client, model, alist, messages):
"""Test that add_note adds documentation link for ValidationException about invalid model identifier."""
# Mock the client error response for access denied
error_response = {
"Error": {
"Code": "AccessDeniedException",
"Message": "An error occurred (AccessDeniedException) when calling the ConverseStream operation: "
"You don't have access to the model with the specified model ID.",
"Code": "ValidationException",
"Message": "An error occurred (ValidationException) when calling the ConverseStream operation: "
"The provided model identifier is invalid.",
}
}
bedrock_client.converse_stream.side_effect = ClientError(error_response, "ConversationStream")
Expand All @@ -1499,7 +1499,7 @@ async def test_add_note_on_access_denied_exception(bedrock_client, model, alist,
"└ Bedrock region: us-west-2",
"└ Model id: m1",
"└ For more information see "
"https://strandsagents.com/latest/user-guide/concepts/model-providers/amazon-bedrock/#model-access-issue",
"https://strandsagents.com/docs/user-guide/concepts/model-providers/amazon-bedrock/#model-identifier-is-invalid",
]


Expand Down Expand Up @@ -1527,7 +1527,7 @@ async def test_add_note_on_validation_exception_throughput(bedrock_client, model
"└ Bedrock region: us-west-2",
"└ Model id: m1",
"└ For more information see "
"https://strandsagents.com/latest/user-guide/concepts/model-providers/amazon-bedrock/#on-demand-throughput-isnt-supported",
"https://strandsagents.com/docs/user-guide/concepts/model-providers/amazon-bedrock/#on-demand-throughput-isnt-supported",
]


Expand Down