Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSM: Fix bad state caused by invalid PutParameter request #6484

Merged
merged 3 commits into from
Jul 7, 2023
Merged
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
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