Skip to content

fix(idempotency): fix serialization of Pydantic idempotency keys for special data types#8066

Open
jontmy wants to merge 1 commit intoaws-powertools:developfrom
jontmy:develop
Open

fix(idempotency): fix serialization of Pydantic idempotency keys for special data types#8066
jontmy wants to merge 1 commit intoaws-powertools:developfrom
jontmy:develop

Conversation

@jontmy
Copy link
Copy Markdown

@jontmy jontmy commented Mar 24, 2026

Issue number: closes #8065

Summary

Changes

  • Updated the Pydantic serialization mode of idempotency keys to use mode="json" instead of relying on the default mode="python"

User experience

Before: Special data types such as UUID and dates cannot be used in idempotency keys because they cannot be serialized by Pydantic's default .model_dump().

After: Setting mode="json" allows Pydantic to convert supported data types (such as UUIDs) to valid JSON values, allowing them to be used as part of idempotency keys. If an unsupported type is used and can't be serialized to JSON, a PydanticSerializationError exception is raised.


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.

@jontmy jontmy requested a review from a team as a code owner March 24, 2026 04:09
@jontmy jontmy requested a review from anafalcao March 24, 2026 04:09
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 24, 2026
@boring-cyborg boring-cyborg bot added the tests label Mar 24, 2026
@boring-cyborg
Copy link
Copy Markdown

boring-cyborg bot commented Mar 24, 2026

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes 10-29 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Idempotency key in idempotent_function fails to serialize dates/UUIDs

1 participant