diff --git a/moto/ssm/models.py b/moto/ssm/models.py index 74f60e58a..fe6c64ee8 100644 --- a/moto/ssm/models.py +++ b/moto/ssm/models.py @@ -1217,7 +1217,12 @@ class SimpleSystemManagerBackend(BaseBackend): ) if len(result) > 0: return result[-1] - + elif len(parameters) > 0: + raise ParameterVersionNotFound( + "Systems Manager could not find version %s of %s. " + "Verify the version and try again." + % (version_or_label, name_prefix) + ) result = list( filter(lambda x: version_or_label in x.labels, parameters) ) diff --git a/tests/test_ssm/test_ssm_boto3.py b/tests/test_ssm/test_ssm_boto3.py index 3301ed32c..ddf033cfc 100644 --- a/tests/test_ssm/test_ssm_boto3.py +++ b/tests/test_ssm/test_ssm_boto3.py @@ -465,8 +465,15 @@ def test_get_parameter_with_version_and_labels(): with pytest.raises(ClientError) as ex: client.get_parameter(Name="test-2:2", WithDecryption=False) + ex.value.response["Error"]["Code"].should.equal("ParameterVersionNotFound") + ex.value.response["Error"]["Message"].should.equal( + "Systems Manager could not find version 2 of test-2. Verify the version and try again." + ) + + with pytest.raises(ClientError) as ex: + client.get_parameter(Name="test-3:2", WithDecryption=False) ex.value.response["Error"]["Code"].should.equal("ParameterNotFound") - ex.value.response["Error"]["Message"].should.equal("Parameter test-2:2 not found.") + ex.value.response["Error"]["Message"].should.equal("Parameter test-3:2 not found.") @mock_ssm