Skip to content

Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocation #8728

Open

Description

@leandrodamascena

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

Activity

  1. added this to the 3.41.0 milestone on Oct 31, 2026
  2. powertools-for-aws-oss-automation commented on Oct 31, 2026

    @powertools-for-aws-oss-automation

    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.

  3. lechakrawarthy commented on Oct 31, 2026

    @lechakrawarthy

    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.

  4. bfs2021 commented on Nov 1, 2026

    @bfs2021

    Claiming this one — will follow AGENTS.md (claim-first flow), verify with the test commands there, and open a PR once assigned.

  5. leandrodamascena commented on Nov 1, 2026

    @leandrodamascena
    ContributorAuthor

    @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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workinggood first issueGood for newcomershelp wantedCould use a second pair of eyes/handsidempotencyIdempotency utility

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions