Closed
Description
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
Metadata
Metadata
Assignees
Type
Projects
Status
Shipped