Bug: Handeling idempotency for Lambda timeout - in progress idempotency not preventing duplicate records

Đang mở
#8,049 6 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

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

Từ ngày 2/4/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

not-a-bug question
Expected Behaviour

I started experiencing error where if lambda timeouts during executing idempotency in-progress is ignored and allows to submit the same lambda request again.

It was implemented within this PR https://github.com/aws-powertools/powertools-lambda-python/pull/1387

After reviewing code I can not find way to override in_progress_expiry_timestamp value via configuration, because I do not want this value to be set to lambda timeout value.

I want this value to be set manually to desire duration for example 1 hour.

Current Behaviour

Lambda idempotency timeout handling was implemented within https://github.com/aws-powertools/powertools-lambda-python/pull/1387

When Lambda timeouts while idempotency is in progress this allows to submit the same payload again.

For example if we passing idempotency_key and payload to make withdrawal within 3rd party API or start step function. If Lambda timeouts while executing it, it allows to repeat this action and ignores idempotency_key.

Currently it is no setting to change field value for in_progress_expiry_timestamp

Code snippet
https://github.com/aws-powertools/powertools-lambda-python/pull/1387/changes#diff-becc2a8b1233bddbb0d38b13a8634ab96bdd5d00f16f0514f6ea1df509c3b1d6R353


        if remaining_time_in_millis:
            now = datetime.datetime.now()
            period = datetime.timedelta(milliseconds=remaining_time_in_millis)
            timestamp = (now + period).timestamp()

            data_record.in_progress_expiry_timestamp = int(timestamp * 1000)
        else:
            warnings.warn(
                "Couldn't determine the remaining time left. "
                "Did you call register_lambda_context on IdempotencyConfig?"
            )
Possible Solution

Allow field in_progress_expiry_timestamp value to be set via configuration.

Steps to Reproduce
  1. Configure idempotency for lambda
  2. Add lambda timeout for 10 seconds
  3. Invoke step function within lambda
  4. After invoking step function within handler add time.sleep(20) - to cause Lambda timeout
  5. Execute Lambda two times and observe that two executions within steps function (should be one)
Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.13

Packaging format used

PyPi

Debugging logs

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.