Repository navigation
Description
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 serializablePossible 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
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsComing soon
Activity
Neeraj111010 commentedon Oct 31, 2026
HI @leandrodamascena
I would like to claim this issue! I'll work on extending
_IdempotencyKeyEncoderto supportset,frozenset, andbytes, and add the requested unit tests.leandrodamascena commentedon Nov 1, 2026
@Neeraj111010 it's yours, assigning you now. Go ahead with the PR, and say in the description how you ran the tests.
Neeraj111010 commentedon Nov 1, 2026
Hi @leandrodamascena! Just wanted to drop a quick note that I've got everything wrapped up here. All 33 tests are passing cleanly and lint checks are completely clear.
Thanks again!
anishsinghhh3-bit commentedon Nov 2, 2026
I would like to work on this issue.
leandrodamascena commentedon Nov 2, 2026
Thanks @anishsinghhh3-bit, this one is already assigned to @Neeraj111010. The Logger audit in #8730 becomes issues this week, keep an eye on it.
fix(idempotency): add deterministic support for set, frozenset, and b…
powertools-for-aws-oss-automation commentedon Nov 14, 2026
Warning
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.