Skip to content

Bug: get_parameters_by_name with raise_on_error=False still raises on transform errors in the decrypt path, and caches None #8594

Open

Description

@leandrodamascena

Expected Behaviour

With raise_on_error=False, a parameter whose transform fails is reported in _errors and does not stop the call, no matter whether it was fetched with GetParameter (decrypt) or GetParameters (batch). Failed transforms are not cached.

Current Behaviour

Two related problems in ssm.py:

  1. _get_parameters_by_name_with_decrypt_option (:534) only catches GetParameterError, and BaseProvider.get hard-codes raise_on_transform_error=True, so a transform failure on a decrypted parameter raises TransformParameterError even in graceful mode. The same payload through the batch path returns None.
  2. The batch path (:664) caches the None from a failed transform for max_age and does not list the name in _errors, while BaseProvider.get explicitly avoids caching None for that reason. A corrected parameter keeps returning None until the cache expires.

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_response("get_parameter", {"Parameter": {"Name": "/a", "Value": "not json", "Type": "String", "Version": 1}}, {"Name": "/a", "WithDecryption": True})
stub.add_response("get_parameters", {"Parameters": [{"Name": "/b", "Value": "not json", "Type": "String", "Version": 1}]}, {"Names": ["/b"]})
stub.activate()

provider.get_parameters_by_name({"/a": {"decrypt": True}, "/b": {}}, transform="json", raise_on_error=False)
# TransformParameterError      expected: {'_errors': ['/a', '/b'], ...}

provider.get_parameters_by_name({"/b": {}}, transform="json", raise_on_error=False)
# {'_errors': [], '/b': None}  and provider.store now caches None for /b

Possible Solution

Catch TransformParameterError in the decrypt path and add the name to errors; in the batch path, skip add_to_cache when the transformed value is None and add the name to _errors.

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!

Activity

  1. Suraj1347 commented on Oct 18, 2026

    @Suraj1347

    Hi! I'd like to work on this issue as my first open-source contribution.

    I plan to investigate the decrypt-path transformation error handling and the caching of failed transformations, then propose a focused fix with regression tests for both cases.

    Could you please confirm that this scope is appropriate and assign the issue to me before I start? Thank you!

  2. leandrodamascena commented on Oct 18, 2026

    @leandrodamascena
    ContributorAuthor

    Hey @Suraj1347 pls go ahead.

  3. added this to the 3.39.0 milestone on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomersparametersParameters utilitytriagePending triage from maintainers

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions