Skip to content

Bug: get_app_config ignores environment and application after the first call #8588

Closed

Description

@leandrodamascena

Expected Behaviour

get_app_config(name, environment=..., application=...) reads from the environment and application passed on every call.

Current Behaviour

The module-level provider is created once under the key "appconfig" in DEFAULT_PROVIDERS (appconfig.py:218) with the first environment/application. Every later call reuses it, so a function that reads two applications or two environments silently gets the first one. The second call below even hits the cache for the wrong app.

Code snippet

from unittest.mock import patch
from aws_lambda_powertools.utilities import parameters
from aws_lambda_powertools.utilities.parameters import AppConfigProvider, get_app_config

calls = []
def fake_get(self, name, **kw):
    calls.append((self.application, self.environment, name)); return b"{}"

parameters.clear_caches()
with patch.object(AppConfigProvider, "_get", fake_get):
    get_app_config("cfg", environment="dev", application="app-a", max_age=0)
    get_app_config("cfg", environment="prod", application="app-b", max_age=0)

print(calls)  # [('app-a', 'dev', 'cfg'), ('app-a', 'dev', 'cfg')]  app-b/prod never used

Possible Solution

Key the default provider by ("appconfig", environment, application) in DEFAULT_PROVIDERS, or recreate it when they differ. clear_caches() must still clear all of them.

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

    @codewithzubair07
    Contributor

    @leandrodamascena Hey, I’d like to work on this issue. I’ll look into the caching problem and try to fix it so different applications and environments use the correct configuration.

  2. leandrodamascena commented on Oct 18, 2026

    @leandrodamascena
    ContributorAuthor

    Hey @codewithzubair07 yeah pls go ahead.

  3. added this to the 3.38.0 milestone on Oct 18, 2026
  4. powertools-for-aws-oss-automation commented on Oct 22, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workinggood first issueGood for newcomersparametersParameters utilitypending-releaseFix or implementation already in dev waiting to be released

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions