Skip to content

Bug: POWERTOOLS_IDEMPOTENCY_DISABLED does not respect truthy values #4390

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

Closed
stevenhoelscher opened this issue May 22, 2024 · 4 comments · Fixed by #4391
Closed

Bug: POWERTOOLS_IDEMPOTENCY_DISABLED does not respect truthy values #4390

stevenhoelscher opened this issue May 22, 2024 · 4 comments · Fixed by #4391
Assignees
Labels
bug Something isn't working idempotency Idempotency utility

Comments

@stevenhoelscher
Copy link

stevenhoelscher commented May 22, 2024

Expected Behaviour

I would expect truthy values to be respected for POWERTOOLS_IDEMPOTENCY_DISABLED:

  • True: ["1", "y", "yes", "t", "true", "on"]
  • False: ["0": "n", "no", "f", "false", "off"]

Current Behaviour

The logic below is accessing the environment variable and bypassing the idempotency layer if it the condition evaluates to True. But it's always evaluating to True unless os.getenv returns None.

if os.getenv(constants.IDEMPOTENCY_DISABLED_ENV):
    return function(*args, **kwargs)

Code snippet

>>> import os
>>> os.environ['POWERTOOLS_IDEMPOTENCY_DISABLED'] = 'false'
>>> bool(os.getenv('POWERTOOLS_IDEMPOTENCY_DISABLED'))
True
>>> bool(None)
False

Possible Solution

Leverage the strtobool function in aws_lambda_powertools.shared.functions to convert the environment variable value into a bool.

Steps to Reproduce

I would recommend setting the value of POWERTOOLS_IDEMPOTENCY_DISABLED to false, which implies the user does not want idempotency to be disabled. In this situation, the Idempotency layer will be bypassed and no records will be recorded in the idempotency store.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.11

Packaging format used

Lambda Layers

Debugging logs

No response

@stevenhoelscher stevenhoelscher added bug Something isn't working triage Pending triage from maintainers labels May 22, 2024
Copy link

boring-cyborg bot commented May 22, 2024

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
Copy link
Contributor

Assigning to @heitorlessa

@leandrodamascena leandrodamascena moved this from Triage to Working on it in Powertools for AWS Lambda (Python) May 22, 2024
@leandrodamascena leandrodamascena added idempotency Idempotency utility and removed triage Pending triage from maintainers labels May 22, 2024
@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (Python) Jun 4, 2024
Copy link
Contributor

github-actions bot commented Jun 4, 2024

⚠️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.

@heitorlessa heitorlessa added the pending-release Fix or implementation already in dev waiting to be released label Jun 10, 2024
Copy link
Contributor

This is now released under 2.39.0 version!

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