Skip to content

fix(parameters): wrap GetParameters client errors in get_parameters_by_name - #8617

Open
Tanmay-Ts wants to merge 2 commits into
aws-powertools:developfrom
Tanmay-Ts:fix/get-parameters-by-name-client-error
Open

Tanmay-Ts wants to merge 2 commits into
aws-powertools:developfrom
Tanmay-Ts:fix/get-parameters-by-name-client-error

Conversation

@Tanmay-Ts

@Tanmay-Ts Tanmay-Ts commented Oct 18, 2026 •

Copy link
Copy Markdown

Issue number: closes #8597

Summary

Changes

  • _get_parameters_by_name now catches any exception from the GetParameters request. With raise_on_error=True it raises GetParameterError (chained with from exc, so the botocore error is available as __cause__). With raise_on_error=False it returns the request's names, which end up under _errors.
  • Previously only InvalidKeyId and InternalServerError were caught, so throttling or any other ClientError escaped raw in both modes.
  • fix(parameters): raise GetParameterError when GetParameters fails in fail-fast mode #8616 already made InvalidKeyId and InternalServerError raise GetParameterError in fail-fast mode. This PR keeps its Failed to fetch parameters: [...] message and appends the botocore error, so the cause is visible without reading __cause__.
  • Per-parameter failures reported in InvalidParameters are unchanged; only request-level failures are affected.
  • This applies to every GetParameters request get_parameters_by_name makes: all-decrypt batches, non-decrypt batches, and the non-decrypted subset of a mixed batch. The decrypted subset of a mixed batch goes through get(), which already wraps errors.

Tests added in tests/functional/parameters/_boto3/test_utilities_parameters.py:

  • Fail-fast: ThrottlingException, InvalidKeyId and InternalServerError, each with decrypt=False and decrypt=True, asserting GetParameterError and the exact Names / WithDecryption sent.
  • Graceful: 11 parameters fetched in two chunks, the first returning one InvalidParameters entry and the second throttled. Asserts _errors == [invalid, throttled] and that the successful values are kept.

On current develop, the throttling cases and the graceful test fail because the ClientError escapes. The InvalidKeyId and InternalServerError cases already raise there since #8616 and fail only because the message doesn't name the error code. With this change, pytest tests/functional/parameters → 190 passed.

User experience

Before:

provider.get_parameters_by_name({"/a": {}})                        # raw botocore ClientError (throttling)
provider.get_parameters_by_name({"/a": {}}, raise_on_error=False)  # raw botocore ClientError (throttling)

After:

provider.get_parameters_by_name({"/a": {}})                        # GetParameterError
provider.get_parameters_by_name({"/a": {}}, raise_on_error=False)  # {"_errors": ["/a"]}

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.

🤖 Generated with Claude Code

…y_name

_get_parameters_by_name only handled InvalidKeyId and InternalServerError,
so throttling or any other ClientError escaped raw in both modes. And in
fail-fast mode, those two handled errors returned failed names that the
caller discarded, so parameters silently went missing.

Any failure of the GetParameters request now raises GetParameterError when
raise_on_error=True, and reports the request's names under _errors when
raise_on_error=False.

Closes aws-powertools#8597

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Tanmay-Ts
Tanmay-Ts requested a review from a team as a code owner October 18, 2026 17:24
@boring-cyborg boring-cyborg Bot added the tests label Oct 18, 2026
@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
@leandrodamascena leandrodamascena added this to the 3.39.0 milestone Oct 19, 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>
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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 lets botocore ClientError escape instead of GetParameterError

2 participants