What this thread does
Do first: identify asynchronous Invoke versus an SQS event source mapping, then persist an idempotency key before executing any repeatable business side effect (idempotency).
Short answer
As of November 2026, use current Lambda and Powertools Python docs. A successful async invocation can still be delivered again because Lambda's queue is eventually consistent. Async delivery. Preserve completed operation results durably.
Choose / don't choose
- Async invocation: choose bounded function-error retries plus an on-failure destination; don't set retries to zero as a substitute for deduplication. Throttling/system retries have a different path. Async handling.
- SQS mapping: choose per-record processing and partial failure reporting; don't let one record's exception replay all completed records. For FIFO, stop at first failure and report failed plus unprocessed messages. SQS behavior.
- Durable operation key: choose a stable business ID across delivery attempts; don't use an invocation request ID or changing timestamp. Scope the key to one business operation. Jerome Van Der Linden and Dariusz Osiennik's April 20, 2022 article explains concurrent duplicates and the side-effect/record-write gap.
Not for: cold-start tuning; see aws-lambda-cut-function-cold-starts-and-cost.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
MaximumRetryAttempts | 0 to suppress function-error retries, or 1/2 if failures are safe to replay; default 2; none prevents duplicate delivery | Async invocation config, not SQS | API, retry semantics |
MaximumEventAgeInSeconds | 60–21600; choose business staleness budget | Async invocation config | API |
FunctionResponseTypes | ["ReportBatchItemFailures"] | SQS event source mapping | SQS guide, mapping API |
batchItemFailures[].itemIdentifier | Failed SQS messageId values; for FIFO, include unprocessed messages after the first failure | SQS handler response | SQS guide |
IdempotencyConfig.event_key_jmespath | order_id only for a decoded per-operation payload with that stable field; extract each SQS body before applying it | Current Powertools Python docs | Idempotency |
raise_on_no_idempotency_key | True to reject absent keys | Current Powertools Python docs | Idempotency |
expires_after_seconds | Documented example 24 * 60 * 60; choose retention covering all legitimate replay paths | Current Powertools Python docs | Idempotency |
Partial batch response became available in the November 23, 2021 SQS feature announcement; use its current response contract, not whole-batch success after swallowing an error.
Order of operations
1. Define the operation key and replay horizon. Decode transport envelopes and apply deduplication per business operation, not to the whole SQS batch. Powertools. 2. Acquire an atomic durable in-progress claim, execute the side effect and persist the completed result; later duplicates return the result. Idempotency article. 3. For SQS, enable the response type and catch per-record failures. Return their identifiers; for FIFO, stop at the first failure and include unprocessed message identifiers too. Throwing from the whole handler defeats partial reporting. SQS. 4. Exercise duplicate-after-success, concurrent duplicate, timeout-after-side-effect and mixed-success batches in an isolated consumer. Check that completed effects remain single and failed records remain retryable; configure discarded-event handling separately. Async, SQS.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
IdempotencyAlreadyInProgressError | Same key already executing | Retry later; do not bypass the durable claim | Powertools |
IdempotencyKeyError | Required key expression returns None | Validate and correct envelope/key extraction | Powertools |
| Entire SQS batch reappears | Top-level exception | Enable mapping response type and return failed record IDs, plus unprocessed FIFO record IDs after the first failure, without throwing the batch | SQS |
n2N8Z's October 5, 2021 timeout report describes stale in-progress records blocking retries after Lambda timeout. Consult current Powertools timeout handling; the historical issue is not evidence that a completed external effect can be replayed safely.
Missing
- The linked source does not confirm: Async function-error retry settings and SQS poller retries are separate controls.
- The linked source does not confirm: partial batch responses reduce unnecessary SQS replay but do not remove the need for idempotency
- The linked source does not confirm: A crash after an external side effect but before marking completion still needs downstream idempotency or an atomic transaction/outbox boundary.
- Actual event schema, source mapping, replay horizon and downstream transaction boundary are unspecified.
order_idis a documented conditional example; no universal JMESPath expression or retry count establishes exactly-once effects.
Checked
2026-11-12; current docs, November 2026. Sources read: Lambda async/SQS/API references, Powertools idempotency, dated SQS announcement idempotency article and n2N8Z report. No invocation or queue commands executed.
Started from a post by @AWS, packaged by the editor. Original post