Skip to content

fix(parameters): raise GetParameterError when GetParameters fails in fail-fast mode - #8616

Merged
leandrodamascena merged 2 commits into
aws-powertools:developfrom
azmi2409:fix-8586-get-parameters-by-name-raise
Oct 22, 2026
Merged

leandrodamascena merged 2 commits into
aws-powertools:developfrom
azmi2409:fix-8586-get-parameters-by-name-raise

Conversation

@azmi2409

@azmi2409 azmi2409 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #8586.

Problem: get_parameters_by_name(..., raise_on_error=True) (the default) returned {} when the underlying GetParameters call failed with InvalidKeyId or InternalServerError — the except block in _get_parameters_by_name turned the names into an error list that is only surfaced when raise_on_error=False. Lambdas kept running without their parameters despite the documented fail-fast behavior ("Raises GetParameterError upon any error").

Fix: in the except block, raise GetParameterError(f"Failed to fetch parameters: {parameter_names}") from exc when raise_on_error is set, before falling back to the error list. Graceful mode (raise_on_error=False) is unchanged — names still aggregate under the _errors key.

Tests: added test_ssm_provider_get_parameters_by_name_raise_on_get_parameters_error (InvalidKeyId, plain batch) and test_ssm_provider_get_parameters_by_name_raise_on_get_parameters_error_decrypt (InternalServerError, all-decrypt WithDecryption batch), both using botocore.stub.Stubber per the issue's repro. Verified: 2 new tests pass; full test_utilities_parameters.py run 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.

…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
@azmi2409
azmi2409 requested a review from a team as a code owner October 18, 2026 17:07
@azmi2409
azmi2409 requested a review from hjgraca October 18, 2026 17:07
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 18, 2026
@boring-cyborg boring-cyborg Bot added the tests label Oct 18, 2026
@boring-cyborg

boring-cyborg Bot commented Oct 18, 2026

Copy link
Copy Markdown

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@leandrodamascena leandrodamascena left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.93%. Comparing base (f94134e) to head (1280cc0).
⚠️ Report is 1 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@azmi2409

azmi2409 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

@sonarqubecloud

Copy link
Copy Markdown

@leandrodamascena
leandrodamascena merged commit 51b1e49 into aws-powertools:develop Oct 22, 2026
13 of 14 checks passed
@boring-cyborg

boring-cyborg Bot commented Oct 22, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

@powertools-for-aws-oss-automation

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

Tanmay-Ts added a commit to Tanmay-Ts/powertools-lambda-python that referenced this pull request Oct 23, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: get_parameters_by_name returns {} instead of raising when GetParameters fails with raise_on_error=True

2 participants