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

Aperta
#8,049 6 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@leandrodamascena ci sta già lavorando.

Dal 2/4/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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

Lingua principale
Python
Stelle
3.3k
Fork
511
Merge medio
3g 8h
PR unite (30g)
92

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aws-powertools/powertools-lambda-python

Tutte le issue di aws-powertools/powertools-lambda-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.