Skip to content

Commit

Permalink
SSM: Fix bad state caused by invalid PutParameter request (#6484)
Browse files Browse the repository at this point in the history
  • Loading branch information
viren-nadkarni authored Jul 7, 2023
1 parent 47bca5b commit 89f2a3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion moto/ssm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2062,7 +2062,11 @@ def put_parameter(
"formed as a mix of letters, numbers and the following 3 symbols .-_"
)
raise ValidationException(invalid_prefix_error)
if not parameter_type and not overwrite and not self._parameters[name]:
if (
not parameter_type
and not overwrite
and not (name in self._parameters and self._parameters[name])
):
raise ValidationException(
"A parameter type is required when you create a parameter."
)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_ssm/test_ssm_boto3.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ def test_put_parameter_no_type():
== "A parameter type is required when you create a parameter."
)

# Ensure backend state is consistent
assert client.describe_parameters()


@mock_ssm
def test_update_parameter():
Expand Down

0 comments on commit 89f2a3c

Please sign in to comment.