Repository navigation
Conversation
…ative fields to_dict returned dataclasses.asdict() unchanged, so a result holding datetime, UUID or Enum values failed to save with IdempotencyPersistenceLayerError and left the record INPROGRESS. from_dict also returned nested dataclasses as plain dicts on replay. Dump JSON-compatible values in to_dict, and rebuild datetime, date, time, UUID, Enum, Decimal and nested dataclasses (including inside lists, tuples, sets and dicts) in from_dict from the field type hints. Values that do not match the declared type are returned untouched, so records stored before this change replay as before. closes aws-powertools#8723
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number: closes #8723
Summary
Changes
DataclassSerializer.to_dictreturneddataclasses.asdict()unchanged, so a result holdingdatetime,UUIDorEnumvalues failed to save withIdempotencyPersistenceLayerErrorand left the recordINPROGRESS.from_dictalso returned nested dataclasses as plain dicts on replay.to_dictnow dumps JSON-compatible values.from_dictrebuildsdatetime,date,time,UUID,Enum,Decimaland nested dataclasses (including inside lists, tuples, sets and dicts) from the field type hints.docs/utilities/idempotency.md.User experience
Before: returning a dataclass with a
datetime/UUID/Enumfield from an idempotent function raised on save; replayed results had nested dataclasses as dicts.After: such results are saved and replayed as the original types.
Verification
tests/functional/idempotency/_boto3/test_idempotency_dataclass_serializer.py; one fails ondevelopwithout the fix and all pass with it.pytest tests/functional/idempotency: 265 passed, 1 skipped.ruff check,ruff format --check, andmypyon the changed module: clean.An AI assistant (Claude Code) helped write this change; I reviewed it and ran the tests myself.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.