Skip to content

Bug: idempotency payloads with set, frozenset or bytes fields cannot be hashed #8725

Closed

Description

@leandrodamascena

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 serializable

Possible 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

Activity

  1. added this to the 3.41.0 milestone on Oct 31, 2026
  2. Neeraj111010 commented on Oct 31, 2026

    @Neeraj111010
    Contributor

    HI @leandrodamascena
    I would like to claim this issue! I'll work on extending _IdempotencyKeyEncoder to support set, frozenset, and bytes, and add the requested unit tests.

  3. leandrodamascena commented on Nov 1, 2026

    @leandrodamascena
    ContributorAuthor

    @Neeraj111010 it's yours, assigning you now. Go ahead with the PR, and say in the description how you ran the tests.

  4. Neeraj111010 commented on Nov 1, 2026

    @Neeraj111010
    Contributor

    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!

  5. anishsinghhh3-bit commented on Nov 2, 2026

    @anishsinghhh3-bit

    I would like to work on this issue.

  6. leandrodamascena commented on Nov 2, 2026

    @leandrodamascena
    ContributorAuthor

    Thanks @anishsinghhh3-bit, this one is already assigned to @Neeraj111010. The Logger audit in #8730 becomes issues this week, keep an eye on it.

  7. powertools-for-aws-oss-automation commented on Nov 14, 2026

    @powertools-for-aws-oss-automation

    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.

  8. added
    pending-releaseFix or implementation already in dev waiting to be released
    and removed
    help wantedCould use a second pair of eyes/hands
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomersidempotencyIdempotency utilitypending-releaseFix or implementation already in dev waiting to be released

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions