Skip to content

Conversation

leandrodamascena
Copy link
Contributor

@leandrodamascena leandrodamascena commented Jun 5, 2023

Issue number: #2362

Summary

Changes

This RP aims to fix the issue with the AppConfig parameter provider retrieving different parameters in the same Lambda execution. The way it is implemented, self._next_token caches token globally and retrieves only the value of the first call, and discards the others.

User experience

from typing import Any

import requests

from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities import parameters
from aws_lambda_powertools.utilities.typing import LambdaContext

logger = Logger()

def lambda_handler(event: dict, context: LambdaContext):
    endpoint_comments_config: Any = parameters.get_app_config(name="config", environment="dev", application="comments", max_age=0)
    
    endpoint_comments_features: Any = parameters.get_app_config(name="features", environment="dev", application="comments", max_age=0)

    logger.info(endpoint_comments_config)
    logger.info(endpoint_comments_features) # <- THIS will print the value of name="config" instead of name="features"

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@leandrodamascena leandrodamascena requested a review from a team as a code owner June 5, 2023 13:57
@leandrodamascena leandrodamascena requested review from rubenfonseca and removed request for a team June 5, 2023 13:57
@boring-cyborg boring-cyborg bot added documentation Improvements or additions to documentation tests labels Jun 5, 2023
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 5, 2023
@leandrodamascena leandrodamascena requested review from heitorlessa and removed request for rubenfonseca June 5, 2023 13:57
@leandrodamascena leandrodamascena linked an issue Jun 5, 2023 that may be closed by this pull request
@github-actions github-actions bot added the bug Something isn't working label Jun 5, 2023
@leandrodamascena leandrodamascena changed the title fix(parameters): fix the appconfig provider's malfunction during multiple invocations. fix(parameters): fix AppConfigProvider retrieves wrong value Jun 5, 2023
@heitorlessa heitorlessa changed the title fix(parameters): fix AppConfigProvider retrieves wrong value fix(parameters): AppConfigProvider retrieving unique configuration names Jun 5, 2023
@heitorlessa heitorlessa changed the title fix(parameters): AppConfigProvider retrieving unique configuration names fix(parameters): AppConfigProvider when retrieving multiple unique configuration names Jun 5, 2023
Signed-off-by: Heitor Lessa <lessa@amazon.nl>
@heitorlessa
Copy link
Contributor

heitorlessa commented Jun 5, 2023

nicely done @leandrodamascena <3

https://media.giphy.com/media/mbhseRYedlG5W/giphy.gif

@heitorlessa heitorlessa merged commit edba331 into aws-powertools:develop Jun 5, 2023
roger-zhangg pushed a commit to roger-zhangg/aws-lambda-powertools-python that referenced this pull request Jun 5, 2023
…nfiguration names (aws-powertools#2378)

Co-authored-by: heitorlessa <lessa@amazon.co.uk>
sthulb pushed a commit that referenced this pull request Jun 19, 2023
…nfiguration names (#2378)

Co-authored-by: heitorlessa <lessa@amazon.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: AppConfigProvider retrieves wrong value
2 participants