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

Ouverte
#8,049 6 commentaires 0 réactions 1 personne assignée Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@leandrodamascena y travaille déjà.

Depuis le 2/4/2026.

Évaluation

Cette issue n'a pas encore été évaluée.

Description

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

Langage dominant
Python
Étoiles
3.3k
Forks
511
Merge moyen
3 j 8 h
PR mergées (30 j)
92

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de aws-powertools/powertools-lambda-python

Toutes les issues de aws-powertools/powertools-lambda-python

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.