Bug: get_parameters_by_name lets botocore ClientError escape instead of GetParameterError
Expected Behaviour
Any failure of the GetParameters call is wrapped in GetParameterError in fail-fast mode, or reported in _errors in graceful mode. The docstring says "Raises GetParameterError upon any error", and get_parameter wraps every exception this way.
Current Behaviour
_get_parameters_by_name_from_batch (ssm.py:628-634) only handles InvalidKeyId and InternalServerError. Throttling or any other ClientError propagates raw in both modes.
Code snippet
from botocore.config import Config
from botocore.stub import Stubber
from aws_lambda_powertools.utilities.parameters import SSMProvider
provider = SSMProvider(boto_config=Config(region_name="us-east-1"))
stub = Stubber(provider.client)
stub.add_client_error("get_parameters", "ThrottlingException")
stub.activate()
provider.get_parameters_by_name({"/a": {}}, raise_on_error=False) # botocore ClientError, expected {'_errors': ['/a']}
provider.get_parameters_by_name({"/a": {}}) # botocore ClientError, expected GetParameterError
Possible Solution
Catch Exception around the call; re-raise as GetParameterError when raise_on_error=True, otherwise return the batch names as errors. Code that catches ClientError around this call today is coding against the bug, since every other function in the utility already wraps it.
Steps to Reproduce
Run the snippet above (it uses botocore.stub.Stubber, no AWS access needed).
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.13
Packaging format used
PyPi
Debugging logs
[!WARNING] This issue is ready to be picked up, by humans or by agents. If you want it, comment here first so we can assign it to you, and please take only one or two issues at a time so others can join in too. The reproduction above runs locally without AWS access. Thanks!
Hi @leandrodamascena, I'd like to take this one. Plan: wrap the botocore ClientError in GetParameterError (chained with from) in the get_parameters_by_name path, and add a functional test with a stubbed ClientError.
Pls go ahead @Tanmay-Ts
[!warning] This issue is now closed. Please be mindful that future comments are hard for our team to see. If you need more assistance, please either reopen the issue, or open a new issue referencing this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
This is now released under 3.39.0 version!