Skip to content

Bug: get_parameters_by_name and get() use different cache keys, so they never share cache entries #8593

Open

Description

@leandrodamascena

Expected Behaviour

A parameter fetched by get("/a") is served from cache by a following get_parameters_by_name({"/a": {}}), and the other way around, as long as it is fresh.

Current Behaviour

get_parameters_by_name builds its cache key as (name, transform) (ssm.py:566 and :664), while BaseProvider._build_cache_key builds (name, transform, is_nested). The two never match, so the same parameter is fetched twice and stored twice. Inside get_parameters_by_name itself, a parameter that goes through the decrypt path (get()) and later through the batch path is also fetched again.

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)
resp1 = {"Parameter": {"Name": "/a", "Value": "v", "Type": "String", "Version": 1}}
resp2 = {"Parameters": [{"Name": "/a", "Value": "v", "Type": "String", "Version": 1}]}
stub.add_response("get_parameter", resp1, {"Name": "/a", "WithDecryption": False})
stub.add_response("get_parameters", resp2, {"Names": ["/a"]})
stub.activate()

provider.get("/a")
provider.get_parameters_by_name({"/a": {}})   # second API call for a value that is fresh in cache
print(list(provider.store))  # [('/a', None, False), ('/a', None)]

Possible Solution

Use self._build_cache_key(name=name, transform=transform) in both places in ssm.py instead of building the tuple by hand.

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. SumiRann1 commented on Oct 18, 2026

    @SumiRann1
    Contributor

    Hii @leandrodamascena, after making a PR on similar issue before #8607, I want to take this as it has high similarities to work on!

  2. leandrodamascena commented on Oct 18, 2026

    @leandrodamascena
    ContributorAuthor

    Hey @SumiRann1 thanks. 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