-
Notifications
You must be signed in to change notification settings - Fork 421
Bug: AppConfigProvider retrieves wrong value #2362
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
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Thanks for opening this issue @scottgerring! I'll review the code again to see how best we can fix this. |
|
This is now released under 2.16.2 version! |
Expected Behaviour
When I call
parameters.get_parameter
using theAppConfigProvider
more than once with different parameter names, I expect to get the corresponding values for each configuration profiles in AppConfig.The code in the
_get
method onAppConfigProvider
stores the configuration session from the first time it is called and re-uses it. The problem is that the configuration session is associated with a single configuration profile, and you can see that thename
parameter is ignored once a session is started. Here you can see the retrieval and storage of the token irrespective of the name of the field:https://github.com/awslabs/aws-lambda-powertools-python/blob/5aece716496e1ce4220b2f2dcb399eceaefc976b/aws_lambda_powertools/utilities/parameters/appconfig.py#L100-L116
I've also noticed that
DEFAULT_PROVIDERS
holds a copy of anAppConfigProvider
established using the application and environment from the first call, and re-uses it:https://github.com/awslabs/aws-lambda-powertools-python/blob/5aece716496e1ce4220b2f2dcb399eceaefc976b/aws_lambda_powertools/utilities/parameters/appconfig.py#L198-L202
I think this means that we'll also not be able to provide a different application or environment for subsequent calls - in this case, I imagine it could be by design (a running application has a single identity and a single environment?)
Current Behavior
The first call works as expected, the second call returns the value from the configuration profile associated with the first call.
Code snippet
These will both end up with the value of
param1
:Possible Solution
Powertools for typescript stores the session tokens keyed on the parameter / configuration profile name:
https://github.com/awslabs/aws-lambda-powertools-typescript/blob/0021536e35ba7046226155055f9ab6b5f988f71f/packages/parameters/src/appconfig/AppConfigProvider.ts#L264-L270
Steps to Reproduce
Fetch two different parameters within the same lambda execution
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.7
Packaging format used
PyPi
Debugging logs
No response
The text was updated successfully, but these errors were encountered: