Bug: DataclassSerializer cannot save datetime/UUID fields and does not rebuild nested dataclasses on replay
Mantenedores costumam responder em até 1 dia
@Suraj1347 já está trabalhando nisso.
Desde 1/11/2026.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 75/100
Direção de pesquisa
Read AGENTS.md for test commands. Edit aws_lambda_powertools/utilities/idempotency/serialization/dataclass.py: make to_dict emit ISO strings and str for UUID, and have from_dict rebuild nested dataclasses via dataclasses.fields(). Add tests in tests/functional/idempotency/_boto3/test_idempotency.py verifying round-trip of UUID/datetime and nested dataclass equality. Done when replayed value equals original.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
[!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
DataclassSerializer saves a dataclass result that contains datetime or UUID fields, and rebuilds nested dataclasses on replay, so the replayed value equals the original.
Current Behaviour
to_dict returns dataclasses.asdict(data) unchanged and save_success dumps it with the plain JSON encoder, which has no datetime/UUID support, so the first call fails with IdempotencyPersistenceLayerError (and then hits the stuck INPROGRESS record described in the companion issue for item 4). This is the same class of bug fixed for Pydantic in #8569. Separately, from_dict does self.__model(**data), so nested dataclasses come back as plain dicts on replay.
Code snippet
import uuid
from dataclasses import dataclass
from datetime import datetime
from aws_lambda_powertools.utilities.idempotency import idempotent_function
from aws_lambda_powertools.utilities.idempotency.serialization.dataclass import DataclassSerializer
@dataclass
class Item:
sku: str
@dataclass
class Order:
id: uuid.UUID
created: datetime
item: Item
@idempotent_function(data_keyword_argument="order", persistence_store=layer, output_serializer=DataclassSerializer)
def process(order: dict) -> Order:
return Order(id=uuid.uuid4(), created=datetime(2026, 1, 1), item=Item(sku="x"))
process(order={"id": 1}) # IdempotencyPersistenceLayerError: Object of type UUID is not JSON serializable
# with only str fields: first call Order(item=Item(sku='x')), replay Order(item={'sku': 'x'})
Possible Solution
In aws_lambda_powertools/utilities/idempotency/serialization/dataclass.py: make to_dict produce JSON-safe values (ISO strings for datetime/date, str for UUID), and in from_dict rebuild nested dataclasses from dataclasses.fields() type hints (and lists of them). Tests in tests/functional/idempotency/_boto3/test_idempotency.py: a dataclass with UUID and datetime round-trips through save and replay, and a nested dataclass comes back as the dataclass, not a dict.
Item 6 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
- Linguagem predominante
- Python
- Estrelas
- 3.3k
- Forks
- 511
- Merge médio
- 3d 8h
- PRs com merge (30d)
- 92
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de aws-powertools/powertools-lambda-python
-
Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocationTalvez já em andamento @lechakrawarthy assumiu há 1 dia. Abertabug good first issue help wanted idempotency
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
aws-powertools/powertools-lambda-python#8728 · 4 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Bug: Redis layer fails the invocation instead of retrying when a record expires between SET NX and GETTalvez já em andamento @coughlmao assumiu há 1 dia. Abertabug good first issue help wanted idempotency
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
aws-powertools/powertools-lambda-python#8727 · 4 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Bug: Redis orphan lock timeout ignores expires_after_seconds and is always 10 secondsTalvez já em andamento @CJstate assumiu há 1 dia. Abertabug good first issue help wanted idempotency
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
aws-powertools/powertools-lambda-python#8726 · 3 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Bug: idempotency payloads with set, frozenset or bytes fields cannot be hashedTalvez já em andamento @Neeraj111010 assumiu há 1 dia. Abertabug good first issue help wanted idempotency
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
aws-powertools/powertools-lambda-python#8725 · 6 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Bug: with a DynamoDB composite key, DataRecord.idempotency_key is the static partition key valueTalvez já em andamento @sumedh-aerram assumiu há 1 dia. Abertabug good first issue help wanted idempotency
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 90/100
aws-powertools/powertools-lambda-python#8724 · 3 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de aws-powertools/powertools-lambda-python
Issues semelhantes
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
aws/sagemaker-python-sdk#6554 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
huggingface/diffusers#15170 ·
Mantenedores costumam responder em até 1 dia
-
[BUG] LLM conflict check ignores MNEMOSYNE_LLM_MAX_TOKENS, so reasoning models return empty repliesAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
mnemosyne-oss/mnemosyne#1325 ·
Mantenedores costumam responder em até 1 dia
-
enhancement meshtastic-2.8
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
pskillen/meshflow-api#459 ·