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

Offen
#8,049 6 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@leandrodamascena arbeitet bereits daran.

Seit 02.4.2026.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

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

Vorherrschende Sprache
Python
Sterne
3.3k
Forks
511
Ø Merge
3 T. 4 Std.
Gemergte PRs (30 T.)
98

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus aws-powertools/powertools-lambda-python

Alle Issues in aws-powertools/powertools-lambda-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.