Bug: Redis layer fails the invocation instead of retrying when a record expires between SET NX and GET
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 85/100
Línea de trabajo
Edita aws_lambda_powertools/utilities/idempotency/persistence/redis.py en _put_record: captura IdempotencyItemNotFoundError después del fallido SET NX y lanza IdempotencyInconsistentStateError. Añade una prueba con un cliente falso que devuelva None en GET, afirmando que la función decorada se ejecuta. Hecho cuando esa prueba pasa y el snippet en el issue devuelve "ok".
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
[!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
- Lenguaje dominante
- Python
- Estrellas
- 3.3k
- Forks
- 511
- Merge medio
- 3 d 8 h
- PR fusionados (30 d)
- 92
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de aws-powertools/powertools-lambda-python
-
Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocationPosiblemente ocupada @lechakrawarthy la tomó hace 1 día. Abiertobug good first issue help wanted idempotency
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
aws-powertools/powertools-lambda-python#8728 · 4 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Bug: Redis orphan lock timeout ignores expires_after_seconds and is always 10 secondsPosiblemente ocupada @CJstate la tomó hace 1 día. Abiertobug good first issue help wanted idempotency
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
aws-powertools/powertools-lambda-python#8726 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Bug: idempotency payloads with set, frozenset or bytes fields cannot be hashedPosiblemente ocupada @Neeraj111010 la tomó hace 1 día. Abiertobug good first issue help wanted idempotency
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
aws-powertools/powertools-lambda-python#8725 · 6 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Bug: with a DynamoDB composite key, DataRecord.idempotency_key is the static partition key valuePosiblemente ocupada @sumedh-aerram la tomó hace 1 día. Abiertobug good first issue help wanted idempotency
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
aws-powertools/powertools-lambda-python#8724 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Bug: output_serializer=PydanticSerializer crashes at import under from __future__ import annotationsPosiblemente ocupada @sumedh-aerram la tomó hace 1 día. Abiertobug good first issue help wanted idempotency
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
aws-powertools/powertools-lambda-python#8722 · 6 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de aws-powertools/powertools-lambda-python
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
aws/sagemaker-python-sdk#6554 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
huggingface/diffusers#15170 ·
Los mantenedores suelen responder en 1 día
-
[BUG] LLM conflict check ignores MNEMOSYNE_LLM_MAX_TOKENS, so reasoning models return empty repliesAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
mnemosyne-oss/mnemosyne#1325 ·
Los mantenedores suelen responder en 1 día
-
enhancement meshtastic-2.8
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
pskillen/meshflow-api#459 ·