Return a sensible error when the parameter is not found

This commit is contained in:
William Richard 2019-11-04 15:30:30 -05:00
parent 3816eba58f
commit 715ff0f7af
No known key found for this signature in database
GPG Key ID: ACD9DA4E735E6D14
2 changed files with 21 additions and 0 deletions

View File

@ -145,6 +145,13 @@ class SimpleSystemManagerResponse(BaseResponse):
result = self.ssm_backend.get_parameter_history(name, with_decryption)
if result is None:
error = {
"__type": "ParameterNotFound",
"message": "Parameter {0} not found.".format(name),
}
return json.dumps(error), dict(status=400)
response = {"Parameters": []}
for parameter_version in result:
param_data = parameter_version.describe_response_object(

View File

@ -879,6 +879,20 @@ def test_get_parameter_history_with_secure_string():
len(parameters_response).should.equal(3)
@mock_ssm
def test_get_parameter_history_missing_parameter():
client = boto3.client("ssm", region_name="us-east-1")
try:
client.get_parameter_history(Name="test_noexist")
raise RuntimeError("Should have failed")
except botocore.exceptions.ClientError as err:
err.operation_name.should.equal("GetParameterHistory")
err.response["Error"]["Message"].should.equal(
"Parameter test_noexist not found."
)
@mock_ssm
def test_add_remove_list_tags_for_resource():
client = boto3.client("ssm", region_name="us-east-1")