Repository navigation
fix(parameters): raise GetParameterError when GetParameters fails in fail-fast mode - #8616
Conversation
…fail-fast mode
get_parameters_by_name(..., raise_on_error=True) returned {} when the
underlying GetParameters call failed with InvalidKeyId or
InternalServerError, letting Lambdas run without their parameters
despite the documented fail-fast behavior. Raise GetParameterError
from the caught exception instead; graceful mode still aggregates the
names under the _errors key.
Fixes aws-powertools#8586
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
leandrodamascena
left a comment
There was a problem hiding this comment.
Thanks @azmi2409! I ran the suite and went through fail-fast, graceful, mixed decrypt batches and the InvalidParameters path with the stubber. The only visible change is the one the docstring always promised: a failed GetParameters now raises instead of returning an empty dict, and the original exception is chained as the cause. Graceful mode is untouched.
Approving now. This goes out in 3.38.0, so it will sit here a bit before I merge. No need to rebase or touch anything, I'll take care of it and you'll get the credit in the release notes. Thank you!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8616 +/- ##
========================================
Coverage 96.93% 96.93%
========================================
Files 318 318
Lines 16067 16069 +2
Branches 1433 1434 +1
========================================
+ Hits 15575 15577 +2
Misses 349 349
Partials 143 143 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for the thorough review, @leandrodamascena! Glad to hear it'll ship in 3.38.0. Let me know if anything needs adjusting before the merge. |
|
51b1e49
into
aws-powertools:develop
|
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |
|
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |
Resolve the conflict with aws-powertools#8616 in _get_parameters_by_name: keep the broader `except Exception` from this branch and aws-powertools#8616's "Failed to fetch parameters: [...]" message, with the botocore error appended so both sets of tests hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>



Fixes #8586.
Problem:
get_parameters_by_name(..., raise_on_error=True)(the default) returned{}when the underlyingGetParameterscall failed withInvalidKeyIdorInternalServerError— theexceptblock in_get_parameters_by_nameturned the names into an error list that is only surfaced whenraise_on_error=False. Lambdas kept running without their parameters despite the documented fail-fast behavior ("Raises GetParameterError upon any error").Fix: in the
exceptblock,raise GetParameterError(f"Failed to fetch parameters: {parameter_names}") from excwhenraise_on_erroris set, before falling back to the error list. Graceful mode (raise_on_error=False) is unchanged — names still aggregate under the_errorskey.Tests: added
test_ssm_provider_get_parameters_by_name_raise_on_get_parameters_error(InvalidKeyId, plain batch) andtest_ssm_provider_get_parameters_by_name_raise_on_get_parameters_error_decrypt(InternalServerError, all-decryptWithDecryptionbatch), both usingbotocore.stub.Stubberper the issue's repro. Verified: 2 new tests pass; fulltest_utilities_parameters.pyrun shows 125 passed with only 2 pre-existing SecretsManager fixture errors (also present on unmodified develop).Note for reviewers (from the issue): code that treated the empty dict as "not found" will now see the exception, which is what the docstring always promised.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.