Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: AppConfig Provider Returning Wrong Configuration #3194

Closed
mekaeelkarim opened this issue Oct 12, 2023 · 5 comments · Fixed by #3195
Closed

Bug: AppConfig Provider Returning Wrong Configuration #3194

mekaeelkarim opened this issue Oct 12, 2023 · 5 comments · Fixed by #3195
Assignees
Labels
bug Something isn't working parameters Parameters utility

Comments

@mekaeelkarim
Copy link

mekaeelkarim commented Oct 12, 2023

Expected Behaviour

When using the AppConfig Provider to fetch user specific configurations at runtime based on the identity of the requester that invokes our lambda function, we expect the correct configuration to be returned. Our AppConfig Application and Environment names are used to instantiate a global AppConfig Provider object at runtime, and the this provider is used to fetch the configuration specific to the requester multiple times throughout the execution of the request in that lambda container. We do not cache the profile and instead rely on the caching that is built into the AppConfig Provider.

Current Behaviour

What we are seeing is that when multiple requests are being made at the same time from different users (across different lambda invocations), the AppConfig provider will be called to fetch the configuration with the right username, but return the wrong configuration profile (it will be called with user A, but return user B's profile). We have tried turning off caching of the profiles and this did not help. All we are doing is calling that initialized AppConfigProvider with the config_name that is specific to each user when we need to fetch that profile. It is important to note that for each request, we only need to fetch one profile that is scoped to the user who made the request.

Code snippet

# Global AppConfig Provider Object
appconfig_client = AppConfigClient(
    application=APPLICATION_NAME,
    environment=ENVIRONMENT_NAME,
)

# Method used to fetch the Configuration
def get_config_as_dict(self, config_name: str) -> Dict[str, Any]:
     logger.info(f"Fetching configuration: {config_name}...")
     return cast(
         dict,
         self._app_config_client.get(
             name=config_name, transform="json", max_age=600
         ),
     )

Possible Solution

No response

Steps to Reproduce

Multiple requests attempting to fetch different configurations at the same time should be able to reproduce this error. The TPS for our service should not be more than 2-3 per second at most. Lambda containers being reused across requests most likely does play a part here.

Powertools for AWS Lambda (Python) version

2.17

AWS Lambda function runtime

3.8

Packaging format used

Lambda Layers

Debugging logs

No response

@mekaeelkarim mekaeelkarim added bug Something isn't working triage Pending triage from maintainers labels Oct 12, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Oct 12, 2023

Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@leandrodamascena leandrodamascena self-assigned this Oct 12, 2023
@leandrodamascena leandrodamascena added parameters Parameters utility and removed triage Pending triage from maintainers labels Oct 12, 2023
@leandrodamascena leandrodamascena moved this from Triage to Working on it in Powertools for AWS Lambda (Python) Oct 12, 2023
@leandrodamascena
Copy link
Contributor

Hello @mekaeelkarim! Thank you for opening this issue. I was able to reproduce the error and will work to fix it. We will likely include this fix in our next release, which is scheduled for tomorrow.

@mekaeelkarim
Copy link
Author

Hi @leandrodamascena, sounds good. Thanks for looking into this!

@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY 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 tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label Oct 13, 2023
@github-actions
Copy link
Contributor

This is now released under 2.26.0 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Oct 13, 2023
@leandrodamascena leandrodamascena moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parameters Parameters utility
Projects
Status: Shipped
2 participants