Skip to content

Feature request: Simplify experience in discovering how much time left before Idempotency record expiration #4818

Closed
@heitorlessa

Description

@heitorlessa

Use case

Provide a method to return a datetime object to make it easier to manipulate for customers building APIs, webhooks, and observable systems.

Docs

As of now, this is what we are expecting customers to do which is error prone for the non-initiated.

...

    # expiry_timestamp could be None so include if set
    expiry_timestamp = idempotent_data.expiry_timestamp
    if expiry_timestamp:
        expiry_time = datetime.datetime.fromtimestamp(int(expiry_timestamp))
        response["x-idempotent-expiration"] = expiry_time.isoformat()

    # Must return the response here
    return response

Solution/User Experience

    # this solution is not correct for edge cases, mostly for illustration
    def get_expiration_datetime(self) -> datetime | None:
        if self.expiry_timestamp:
            return datetime.datetime.fromtimestamp(int(self.expiry_timestamp))
        return None

Alternative solutions

Customers use the `expiry_timestamp` which they need to convert and manipulate from scratch.

https://docs.powertools.aws.dev/lambda/python/latest/utilities/idempotency/#manipulating-the-idempotent-response

Acknowledgment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestfeature requestgood first issueGood for newcomershelp wantedCould use a second pair of eyes/handsidempotencyIdempotency utilityv3Features that will be included in Powertools v3.

    Type

    No type

    Projects

    Status

    Shipped

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions