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

Aberta Para iniciantes
#8,728 2 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

@lechakrawarthy já está trabalhando nisso.

Desde 31/10/2026.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
85/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
aws, python
Domínio
backend

Direção de pesquisa

Comece em aws_lambda_powertools/utilities/idempotency/idempotency.py onde strtobool é chamado para ambos os decoradores. Verifique resolve_truthy_env_var_choice em aws_lambda_powertools/shared/functions.py para ver se se encaixa, caso contrário adicione um helper que retorna False para valores vazios ou não analisáveis. Adicione testes para que vazio, "maybe" e não definido executem a função enquanto "true" pula a idempotência; feito significa nenhum ValueError e CI passa.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug good first issue help wanted idempotency

[!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

Linguagem predominante
Python
Estrelas
3.3k
Forks
511
Merge médio
3d 12h
PRs com merge (30d)
93

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de aws-powertools/powertools-lambda-python

Todas as issues de aws-powertools/powertools-lambda-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.