Skip to content

Bug: set_parameter and set_secret do not invalidate the cached value #8599

Open

Description

@leandrodamascena

Expected Behaviour

After set_parameter("/a", "new") or set_secret("s", "new") on a provider that had /a or s cached, the next get returns the new value.

Current Behaviour

SSMProvider.set (ssm.py:363) and SecretsProvider.set never touch self.store, so get keeps returning the old value for up to max_age seconds from the same provider instance (the module-level default provider in the high-level functions). The docs do not warn about this.

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": "old", "Type": "String", "Version": 1}}, {"Name": "/a", "WithDecryption": False})
stub.add_response("put_parameter", {"Version": 2, "Tier": "Standard"}, None)
stub.activate()

provider.get("/a")                            # 'old'
provider.set("/a", "new", overwrite=True)
print(provider.get("/a"))                     # 'old'  served from cache

Possible Solution

After a successful write, remove every store entry whose key starts with the parameter name (all transforms), in both providers.

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 a second open-source contribution. I've already expressed interest in issue #8594, and I plan to keep my work limited to these two issues.

    I'll investigate cache invalidation after successful parameter and secret writes and propose a focused fix with regression tests.

    Could you please confirm that this issue is available and that the proposed scope is appropriate before I proceed? 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