SSM Parameter Store Error Message When Requesting Invalid Version (#3977)
* Implement correct error when requesting specific version of a parameter which exists but does not have this version * removing trailing whitespace causing lint failure * Adding unit tests and fixing linting for new error handling * Fixing small bug in response message * Revert change in get_parameters as versioning is not currently implemented in this method. Will fix as a separate PR
This commit is contained in:
parent
7947b1e001
commit
b670962c5e
@ -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)
|
||||
)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user