diff --git a/src/strands/models/bedrock.py b/src/strands/models/bedrock.py index 5b7a2f34e..4a29741ef 100644 --- a/src/strands/models/bedrock.py +++ b/src/strands/models/bedrock.py @@ -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 ( @@ -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 diff --git a/tests/strands/models/test_bedrock.py b/tests/strands/models/test_bedrock.py index 9c565d4f4..ef771ce87 100644 --- a/tests/strands/models/test_bedrock.py +++ b/tests/strands/models/test_bedrock.py @@ -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") @@ -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", ] @@ -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", ]