Bug: Redis layer fails the invocation instead of retrying when a record expires between SET NX and GET
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 85/100
Rechercherichtung
Bearbeite aws_lambda_powertools/utilities/idempotency/persistence/redis.py in _put_record: fange IdempotencyItemNotFoundError ab nach dem fehlgeschlagenen SET NX und raise IdempotencyInconsistentStateError. Füge einen Test mit einem Fake-Client hinzu, der bei GET None zurückgibt, und assert dass die dekorierte Funktion ausgeführt wird. Erledigt, wenn dieser Test besteht und das Snippet im Issue "ok" zurückgibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
[!WARNING]
For contributors, human or agent. Comment here to claim this issue and wait for the assignment before opening a PR; if two PRs show up, the assignee's stays. AI-assisted work is welcome, say so in the PR and tell us how you verified it: run the tests yourself and paste what you saw, do not describe runs you did not do. Read AGENTS.md first, it has the commands and the rules the CI enforces. This goes into 3.41.0.
Expected Behaviour
When a Redis record expires between the SET NX that fails and the GET that follows, the Redis layer behaves like the DynamoDB layer: it raises IdempotencyInconsistentStateError, which the handler's retry loop turns into a retry, and the invocation succeeds.
Current Behaviour
In CachePersistenceLayer._put_record, the GET after a failed SET NX goes through _get_record, which raises IdempotencyItemNotFoundError. That exception is not handled there, escapes _put_record and is wrapped as IdempotencyPersistenceLayerError, so the invocation fails for a race that is expected and recoverable.
Code snippet
# fake client: SET NX returns None (key existed), the following GET returns None (key expired in between)
layer = CachePersistenceLayer(client=racy_client)
@idempotent_function(data_keyword_argument="order", persistence_store=layer)
def process(order):
return "ok"
process(order={"id": 1}) # IdempotencyPersistenceLayerError, expected: retried and "ok"
Compare with DynamoDBPersistenceLayer._put_record, where the equivalent race raises IdempotencyInconsistentStateError.
Possible Solution
In aws_lambda_powertools/utilities/idempotency/persistence/redis.py, _put_record: catch IdempotencyItemNotFoundError around the read that follows the failed SET NX and raise IdempotencyInconsistentStateError. Add a test with a fake client that returns None on that GET and assert the decorated function runs.
Item 10 of the Idempotency audit in #8603. No AWS resources needed.
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.13
Packaging format used
PyPi
Debugging logs
No response
- Vorherrschende Sprache
- Python
- Sterne
- 3.3k
- Forks
- 511
- Ø Merge
- 3 T. 8 Std.
- Gemergte PRs (30 T.)
- 92
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus aws-powertools/powertools-lambda-python
-
Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocationEvtl. vergeben @lechakrawarthy hat das heute übernommen. Offenbug good first issue help wanted idempotency
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
aws-powertools/powertools-lambda-python#8728 · 4 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug: Redis orphan lock timeout ignores expires_after_seconds and is always 10 secondsEvtl. vergeben @CJstate hat das heute übernommen. Offenbug good first issue help wanted idempotency
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
aws-powertools/powertools-lambda-python#8726 · 3 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug: idempotency payloads with set, frozenset or bytes fields cannot be hashedEvtl. vergeben @Neeraj111010 hat das heute übernommen. Offenbug good first issue help wanted idempotency
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
aws-powertools/powertools-lambda-python#8725 · 4 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug: with a DynamoDB composite key, DataRecord.idempotency_key is the static partition key valueEvtl. vergeben @sumedh-aerram hat das heute übernommen. Offenbug good first issue help wanted idempotency
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
aws-powertools/powertools-lambda-python#8724 · 3 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug: output_serializer=PydanticSerializer crashes at import under from __future__ import annotationsEvtl. vergeben @sumedh-aerram hat das heute übernommen. Offenbug good first issue help wanted idempotency
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
aws-powertools/powertools-lambda-python#8722 · 6 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in aws-powertools/powertools-lambda-python
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
btclib-org/btclib-node#2198 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Remove the em dashes from the skill smart-account referenceEvtl. vergeben @Vamsi-2581 hat das heute übernommen. Offenagent-ready area: docs documentation good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Soneso/stellar-agent-wallet#541 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
sususweet/midea_auto_cloud#285 ·
Maintainer antworten meist innerhalb von 1 Tag
-
2026-11 documentation good first issue gsoc-2027 project: gsoc
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
alphaonelabs/website#1154 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag