Skip to content

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

Closed

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
    Contributor

    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
  4. powertools-for-aws-oss-automation commented on Oct 29, 2026

    @powertools-for-aws-oss-automation

    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.

  5. added
    pending-releaseFix or implementation already in dev waiting to be released
    and removed
    triagePending triage from maintainers
    on Oct 29, 2026
  6. github-actions commented on Nov 3, 2026

    @github-actions
    Contributor

    This is now released under 3.39.0 version!

  7. removed
    pending-releaseFix or implementation already in dev waiting to be released
    on Nov 3, 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 utility

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions