Skip to content

Feature request: Idempotency prefix is susceptible to refactoring #5897

@lbustelo

Description

@lbustelo

Use case

Problem:

Using aws-lambda-powertools==3.4.1

The prefix to the Idempotency key is hardcoded to force a fully qualified name based on the location of the function that uses the decorator. There is no simple way of modifying this behavior in order to make that prefix some static value.

persistence_store.configure(config, f"{self.function.__module__}.{self.function.__qualname__}")

This makes the Idempotency susceptible to future code refactoring. To prevent duplicate handling you can either

  1. Never move or rename the function decorated with @idempotent_function
  2. Or, migrate all the keys in your Persistent Store

Solution/User Experience

A solution is to provide a way to override the key prefix on the @idempotent_function function. An optional argument like idempotency_key_prefix that allows a user to provided a fix string. This would allow freedom of refactoring (or even have multiple functions that are controlled by the same idempotency key space).

Considerations:

  • This should only control the prefix. The standard behavior of appending #<hash of arguments> would stay intact
  • Not sure if this new feature should force the user to specify the entire prefix, or only the part that goes after the <lambda_name>. I lean towards the full prefix, and let the user decide how to fully qualify the key.

Alternative solutions

Acknowledgment

Metadata

Metadata

Labels

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions