Repository navigation
fix(parameters): ignore malformed POWERTOOLS_PARAMETERS_SSM_DECRYPT instead of crashing - #8839
Open
saquibjawedbit wants to merge 1 commit into
Open
saquibjawedbit wants to merge 1 commit into
saquibjawedbit wants to merge 1 commit into
Conversation
…nstead of crashing An empty or unparsable value made every SSM lookup raise ValueError before any API call. The six SSM entry points now read the variable through the shared resolve_bool_env_var, which warns with PowertoolsUserWarning and falls back to False. An explicit decrypt argument still takes precedence and the variable is not read.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number:
closes #8798
Summary
Changes
The six SSM entry points now read
POWERTOOLS_PARAMETERS_SSM_DECRYPTthrough the sharedresolve_bool_env_varfrom #8783, as suggested in the issue. Same shape as #8734 did for idempotency.aws_lambda_powertools/utilities/parameters/ssm.py: inSSMProvider.get,SSMProvider.get_multiple,SSMProvider.get_parameters_by_name,get_parameter,get_parametersandget_parameters_by_name, replaceresolve_truthy_env_var_choice(env=os.getenv(..., "false"), choice=decrypt)withif decrypt is None: decrypt = resolve_bool_env_var(constants.PARAMETERS_SSM_DECRYPT_ENV). The env var is only read when nodecryptargument is passed. The now-unusedosandresolve_truthy_env_var_choiceimports are removed.tests/functional/parameters/_boto3/test_utilities_parameters.py: functional tests across all six public entry points, usingbotocore.stub.Stubberto assert theWithDecryptionvalue sent to SSM:""and"maybe": the lookup succeeds without decryption and emits aPowertoolsUserWarningnaming the variable (12 cases)."true","1","false","0": decryption follows the variable and no warning is emitted (24 cases).decrypt=True/decrypt=Falsewith the variable set to"maybe": the argument wins and no warning is emitted (12 cases).No existing tests were changed. No docs change: the documented default (
false) and the precedence of thedecryptargument are unchanged.User experience
Before: with
POWERTOOLS_PARAMETERS_SSM_DECRYPT=""(or any value that is not a recognised boolean) and nodecryptargument, every SSM lookup raisedValueError: invalid truth value ''before calling SSM.After: the lookup goes ahead without decryption (the documented default) and a
PowertoolsUserWarningis emitted:Valid values behave as before. An explicit
decrypt=argument still takes precedence, and the variable is not read at all in that case.Verification
AI-assisted; I ran the tests below myself and pasted the output.
Local run on macOS, Python 3.13.15, env synced with
uv sync --locked --extra all --extra redis --extra datamasking --extra valkey --extra auth-sigv4a(themake devdeps). SSM calls are stubbed withbotocore.stub.Stubber, which validates request parameters against the SSM service model; I did not run this against a real SSM endpoint. The fix happens before any SDK call, and the requests sent are the same ones the existing code already sends fordecrypt=False.Fails before the fix (new tests,
ssm.pyfromorigin/develop):(The 36 passing cases are the valid-value and explicit-argument tests, which guard existing behaviour and pass on both.)
Passes after the fix:
Parameters and shared-function suites:
Lint and types:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.