Skip to content

Bug: parameters cache key ignores sdk_options, decrypt and recursive, so different requests share one cached value #8591

Open

Description

@leandrodamascena

Expected Behaviour

Two calls that fetch different data get different cache entries: get("flags", flag="a") vs flag="b" on the AppConfig extension, get_secret("s", VersionStage="AWSPREVIOUS") vs AWSCURRENT, get("/sec") vs get("/sec", decrypt=True), get_multiple("/p", recursive=False) vs recursive=True.

Current Behaviour

BaseProvider._build_cache_key (base.py:239) uses (name, transform, is_nested). sdk_options (base.py:101), decrypt and recursive all change the returned data but are not part of the key, so the second call is served the first call's value for max_age seconds. On SSM that means ciphertext returned to a decrypt=True call and a non-recursive subset returned to a recursive call.

Code snippet

from botocore.config import Config
from botocore.stub import Stubber
from aws_lambda_powertools.utilities.parameters import SecretsProvider

provider = SecretsProvider(boto_config=Config(region_name="us-east-1"))
stub = Stubber(provider.client)
stub.add_response("get_secret_value", {"SecretString": "previous-value"}, {"SecretId": "s", "VersionStage": "AWSPREVIOUS"})
stub.activate()

print(provider.get("s", VersionStage="AWSPREVIOUS"))  # 'previous-value'
print(provider.get("s", VersionStage="AWSCURRENT"))   # 'previous-value' from cache, no API call

# same with SSMProvider: get("/sec") then get("/sec", decrypt=True) returns the cached ciphertext,
# and get_multiple("/p", recursive=False) then recursive=True returns the non-recursive subset.

Possible Solution

Include a stable, hashable rendering of sdk_options in _build_cache_key, and have SSMProvider add decrypt/recursive to the key (they are passed as options already). Existing tests that assert cache hits across these calls will need adjusting.

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. added this to the 3.38.0 milestone on Oct 18, 2026
  2. mayuriphad commented on Oct 18, 2026

    @mayuriphad

    I'd like to take this one. Plan: add sdk_options (which carries decrypt and recursive on SSM, VersionStage on Secrets, flag on the AppConfig extension) to the cache key in BaseProvider, serialized so unhashable values work, plus Stubber tests for each case from the report.

  3. leandrodamascena commented on Oct 18, 2026

    @leandrodamascena
    ContributorAuthor

    Hey @mayuriphad pls go ahead.

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