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

オープン
#8,049 コメント 6 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@leandrodamascena がすでに取り組んでいます。

2026年4月2日 から。

評価

この issue はまだ評価されていません。

説明

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

主要言語
Python
スター
3.3k
フォーク
511
平均マージ
3日 8時間
マージ済み PR(30日)
92

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aws-powertools/powertools-lambda-python のほかの issue

aws-powertools/powertools-lambda-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。