Bug: with a DynamoDB composite key, DataRecord.idempotency_key is the static partition key value
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 90/100
Piste de recherche
Lis aws_lambda_powertools/utilities/idempotency/persistence/dynamodb.py, en te concentrant sur _item_to_data_record. Modifie idempotency_key pour utiliser sort_key_attr lorsqu'il est défini. Ajoute des tests utilisant botocore.stub.Stubber sur le client de la couche avec sort_key_attr et un response_hook pour vérifier la clé, plus un test de succès de cache local. Terminé lorsque les nouveaux tests passent et que la clé reflète la valeur de tri.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
[!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
With a composite key (sort_key_attr set), DataRecord.idempotency_key is the record's own key, the value stored in the sort key, so the local cache, the response_hook and the IdempotencyAlreadyInProgressError message refer to the actual record.
Current Behaviour
DynamoDBPersistenceLayer._item_to_data_record sets idempotency_key=data[self.key_attr], which with a composite key is the static partition key value (static_pk_value, idempotency#<function> by default) for every record. So use_local_cache stores every record under one key and never hits for records written elsewhere, the response_hook receives idempotency_key='idempotency#myfn' (the docs example reads that field), and the in-progress error message shows the static value.
Code snippet
from aws_lambda_powertools.utilities.idempotency import DynamoDBPersistenceLayer
layer = DynamoDBPersistenceLayer(table_name="t", sort_key_attr="sk", static_pk_value="idempotency#fn")
record = layer._item_to_data_record(
{"id": {"S": "idempotency#fn"}, "sk": {"S": "fn#abc"}, "status": {"S": "COMPLETED"}, "expiration": {"N": "9999999999"}, "data": {"S": "{}"}},
)
record.idempotency_key # 'idempotency#fn', expected 'fn#abc'
For the public-API test, use botocore.stub.Stubber on the layer's client like the existing composite-key tests do, and assert on what the response_hook receives.
Possible Solution
In aws_lambda_powertools/utilities/idempotency/persistence/dynamodb.py, _item_to_data_record: idempotency_key=data[self.sort_key_attr] if self.sort_key_attr else data[self.key_attr]. Add a test with sort_key_attr and a response_hook asserting the key, and one for the local cache hit.
Item 7 of the Idempotency audit in #8603. No AWS resources needed, the existing tests stub DynamoDB.
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.13
Packaging format used
PyPi
Debugging logs
No response
- Langage dominant
- Python
- Étoiles
- 3.3k
- Forks
- 511
- Merge moyen
- 3 j 8 h
- PR mergées (30 j)
- 92
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de aws-powertools/powertools-lambda-python
-
Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocationPeut-être pris @lechakrawarthy l’a pris il y a 1 jour. Ouvertebug good first issue help wanted idempotency
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
aws-powertools/powertools-lambda-python#8728 · 4 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Bug: Redis layer fails the invocation instead of retrying when a record expires between SET NX and GETPeut-être pris @coughlmao l’a pris il y a 1 jour. Ouvertebug good first issue help wanted idempotency
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
aws-powertools/powertools-lambda-python#8727 · 4 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Bug: Redis orphan lock timeout ignores expires_after_seconds and is always 10 secondsPeut-être pris @CJstate l’a pris il y a 1 jour. Ouvertebug good first issue help wanted idempotency
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
aws-powertools/powertools-lambda-python#8726 · 3 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Bug: idempotency payloads with set, frozenset or bytes fields cannot be hashedPeut-être pris @Neeraj111010 l’a pris il y a 1 jour. Ouvertebug good first issue help wanted idempotency
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
aws-powertools/powertools-lambda-python#8725 · 4 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Bug: output_serializer=PydanticSerializer crashes at import under from __future__ import annotationsPeut-être pris @sumedh-aerram l’a pris il y a 1 jour. Ouvertebug good first issue help wanted idempotency
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
aws-powertools/powertools-lambda-python#8722 · 6 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de aws-powertools/powertools-lambda-python
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
pytest-dev/pyfakefs#1367 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
IFEvalG exclude_word_harder misses the keyword next to punctuation, at the start or end of the text, and in other letter casePeut-être pris @damienen l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
allenai/open-instruct#2151 ·
Les mainteneurs répondent en général sous 1 jour
-
feat(plan): support convertorLabels and convertorAffinity in Plan resourcePeut-être pris @AmenB l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
RedHatQE/openshift-python-wrapper#2849 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 25 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
libnativeapi/nativeapi#21 ·