Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocation
[!WARNING] For contributors, human or agent. Comment here to claim this issue and wait for the assignment before opening a PR; if two PRs show up, the assignee's stays. AI-assisted work is welcome, say so in the PR and tell us how you verified it: run the tests yourself and paste what you saw, do not describe runs you did not do. Read AGENTS.md first, it has the commands and the rules the CI enforces. This goes into 3.41.0.
Expected Behaviour
POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty string or to a value that is not a recognised boolean is treated as "not disabled", possibly with a warning. Only truthy values disable idempotency.
Current Behaviour
Both idempotent and idempotent_function call strtobool(os.getenv("POWERTOOLS_IDEMPOTENCY_DISABLED", "false")), and strtobool("") raises ValueError: invalid truth value '', so every invocation crashes before the handler runs. "0", "no" and "False" work. An empty value is easy to end up with in IaC templates and CI variables.
Code snippet
import os
os.environ["POWERTOOLS_IDEMPOTENCY_DISABLED"] = ""
@idempotent_function(data_keyword_argument="order", persistence_store=layer)
def process(order):
return "ok"
process(order={"id": 1}) # ValueError: invalid truth value ''
Possible Solution
In aws_lambda_powertools/utilities/idempotency/idempotency.py, resolve the variable once with a helper that returns False for empty or unparsable values (and logs a debug message), and use it in both decorators. Check whether resolve_truthy_env_var_choice in aws_lambda_powertools/shared/functions.py already fits. Tests: "", "maybe" and unset all run the function; "true" skips idempotency.
Item 11 of the Idempotency audit in #8603. No AWS resources needed.
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.13
Packaging format used
PyPi
Debugging logs
No response
[!note] For those interested in contributing, please leave a comment below so that we can assign the issue to you and make sure we don't duplicate efforts. If you have any further questions, please don't hesitate to ask below or on our Discord server.
Hi! I'd like to work on this one. My plan is to resolve POWERTOOLS_IDEMPOTENCY_DISABLED once with a helper that treats empty or unparsable values as "not disabled" (with a debug log), use it in both idempotent and idempotent_function, and add functional tests for "", "maybe", unset and "true". I'll wait for assignment before opening a PR.
Claiming this one — will follow AGENTS.md (claim-first flow), verify with the test commands there, and open a PR once assigned.
@lechakrawarthy you asked first, it's yours. @bfs2021 thanks for following the claim-first flow, this one was already taken; the Logger audit in #8730 will turn into issues this week, keep an eye on it.
[!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 reopen the issue, or open a new issue referencing this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
This is now released under 3.41.0 version!