Bug: idempotency payloads with set, frozenset or bytes fields cannot be hashed
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 80/100
Direzione di ricerca
Inizia in persistence/base.py nel metodo _IdempotencyKeyEncoder.default, che gestisce Enum, date/time, UUID e PurePath. Estendilo per codificare set/frozenset come liste ordinate e bytes come base64. Aggiungi test che verificano che insiemi uguali in ordine diverso producano la stessa chiave e bytes funzioni; esegui la suite secondo AGENTS.md per confermare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
[!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
A dataclass or Pydantic payload with set, frozenset or bytes fields can be used as the idempotency payload; the key hash is computed deterministically.
Current Behaviour
_IdempotencyKeyEncoder in persistence/base.py handles Enum, date/time, UUID and PurePath only. A set field makes the key computation fail with IdempotencyPersistenceLayerError: Failed to save in progress record to idempotency store - Object of type set is not JSON serializable, which reads like a store outage rather than an unsupported payload.
Code snippet
from dataclasses import dataclass
from aws_lambda_powertools.utilities.idempotency import idempotent_function
@dataclass
class Payload:
id: int
tags: set
@idempotent_function(data_keyword_argument="payload", persistence_store=layer)
def process(payload: Payload):
return "ok"
process(payload=Payload(1, {"a"})) # IdempotencyPersistenceLayerError ... Object of type set is not JSON serializable
Possible Solution
Extend _IdempotencyKeyEncoder.default: encode set/frozenset as a sorted list (sort by repr when elements are not comparable) and bytes as base64. Add tests asserting that the same payload with the same set in a different insertion order produces the same key, and that bytes works.
Item 8 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
- Lingua principale
- Python
- Stelle
- 3.3k
- Fork
- 511
- Merge medio
- 3g 4h
- PR unite (30g)
- 98
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aws-powertools/powertools-lambda-python
-
Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocationForse già presa @lechakrawarthy l’ha presa 3 giorni fa. Apertabug good first issue help wanted idempotency
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
aws-powertools/powertools-lambda-python#8728 · 4 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Bug: Redis layer fails the invocation instead of retrying when a record expires between SET NX and GETForse già presa @coughlmao l’ha presa 3 giorni fa. Apertabug good first issue help wanted idempotency
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
aws-powertools/powertools-lambda-python#8727 · 4 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Bug: Redis orphan lock timeout ignores expires_after_seconds and is always 10 secondsForse già presa @CJstate l’ha presa 3 giorni fa. Apertabug good first issue help wanted idempotency
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
aws-powertools/powertools-lambda-python#8726 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Bug: with a DynamoDB composite key, DataRecord.idempotency_key is the static partition key valueForse già presa @sumedh-aerram l’ha presa 3 giorni fa. Apertabug good first issue help wanted idempotency
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
aws-powertools/powertools-lambda-python#8724 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Bug: output_serializer=PydanticSerializer crashes at import under from __future__ import annotationsForse già presa @sumedh-aerram l’ha presa 3 giorni fa. Apertabug good first issue help wanted idempotency
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
aws-powertools/powertools-lambda-python#8722 · 6 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di aws-powertools/powertools-lambda-python
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
microsoft/onnxscript#3155 ·
I maintainer di solito rispondono entro 4 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
bug docs severity:low
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
docs good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100