Bug: DataclassSerializer cannot save datetime/UUID fields and does not rebuild nested dataclasses on replay
メンテナーはふだん 1 日以内に返信
@Suraj1347 がすでに取り組んでいます。
2026年11月1日 から。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
[!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
- 主要言語
- Python
- スター
- 3.3k
- フォーク
- 511
- 平均マージ
- 3日 8時間
- マージ済み PR(30日)
- 92
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
aws-powertools/powertools-lambda-python のほかの issue
-
Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocation対応中かも @lechakrawarthy が 2 日前に担当しました。 オープンbug good first issue help wanted idempotency
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
aws-powertools/powertools-lambda-python#8728 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Bug: Redis layer fails the invocation instead of retrying when a record expires between SET NX and GET対応中かも @coughlmao が 2 日前に担当しました。 オープンbug good first issue help wanted idempotency
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
aws-powertools/powertools-lambda-python#8727 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Bug: Redis orphan lock timeout ignores expires_after_seconds and is always 10 seconds対応中かも @CJstate が 2 日前に担当しました。 オープンbug good first issue help wanted idempotency
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
aws-powertools/powertools-lambda-python#8726 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Bug: idempotency payloads with set, frozenset or bytes fields cannot be hashed対応中かも @Neeraj111010 が 2 日前に担当しました。 オープンbug good first issue help wanted idempotency
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
aws-powertools/powertools-lambda-python#8725 · コメント 6 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Bug: with a DynamoDB composite key, DataRecord.idempotency_key is the static partition key value対応中かも @sumedh-aerram が 2 日前に担当しました。 オープンbug good first issue help wanted idempotency
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
aws-powertools/powertools-lambda-python#8724 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
aws-powertools/powertools-lambda-python の issue をすべて見る
似ている issue
-
cost:cheap practicality:seen-in-the-wild severity:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
fairagro/m4.2_advanced_middleware_api#620 ·
メンテナーはふだん 1 日以内に返信
-
area:security effort:S priority:P2 provider:local-libvirt status:ready type:docs
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
randomparity/kdive#3495 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
microsoft/markitdown#2820 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信