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

Đang mở Phù hợp với người mới
#8,728 4 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@lechakrawarthy đang làm issue này rồi.

Từ ngày 1/11/2026.

  • #8734 của @lechakrawarthy — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
85/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
aws, python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu trong aws_lambda_powertools/utilities/idempotency/idempotency.py nơi strtobool được gọi cho cả hai decorators. Kiểm tra resolve_truthy_env_var_choice trong aws_lambda_powertools/shared/functions.py để xem có phù hợp không, nếu không hãy thêm một helper trả về False cho các giá trị rỗng hoặc không thể phân tích. Thêm các test để rỗng, "maybe" và chưa được thiết lập chạy hàm trong khi "true" bỏ qua idempotency; hoàn thành nghĩa là không có ValueError và CI pass.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Python
Star
3.3k
Fork
511
Merge trung bình
3 ngày 8 giờ
Pull request đã merge (30 ngày)
92

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của aws-powertools/powertools-lambda-python

Tất cả issue của aws-powertools/powertools-lambda-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.