You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: Idempotency prefix is susceptible to refactoring #5897
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.
This makes the Idempotency susceptible to future code refactoring. To prevent duplicate handling you can either
Never move or rename the function decorated with @idempotent_function
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.
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link
I'm not against adding this feature as long as we add a clear disclaimer to the docs / API docs explaining that changing this value on existing functions will void the idempotency.
Regarding the implementation, I'd agree with your suggestion of replacing the full prefix. Basically you'd either let us decide the prefix, or take full control of it.
Will wait for other maintainers to weigh in before adding it to the backlog.
Hey @lbustelo , thanks for opening a feature request.
This would certainly help during refactoring and also give more freedom to pick your own key. I agree with @dreamorosi to leave it to user completely once they want to customize it. That will create clear responsibility boundary between library authors and users.
Hi @lbustelo! Thanks for opening this issue. I'm not very happy with the name of the idempotency_key_custom_prefix parameter and I think we can find a better one.
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.
I agree with letting the customer decide what they want as a prefix and not making assumptions here.
On second thought, it doesn't make much sense to add idempotency_key to the parameter name, it's implicit that this is part of the idempotency mechanism. I'm refactoring to call the parameter as key_prefix.
Activity
boring-cyborg commentedon Jan 22, 2025
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link
dreamorosi commentedon Jan 22, 2025
Hi @lbustelo, thank you for opening the issue.
I'm not against adding this feature as long as we add a clear disclaimer to the docs / API docs explaining that changing this value on existing functions will void the idempotency.
Regarding the implementation, I'd agree with your suggestion of replacing the full prefix. Basically you'd either let us decide the prefix, or take full control of it.
Will wait for other maintainers to weigh in before adding it to the backlog.
am29d commentedon Jan 22, 2025
Hey @lbustelo , thanks for opening a feature request.
This would certainly help during refactoring and also give more freedom to pick your own key. I agree with @dreamorosi to leave it to user completely once they want to customize it. That will create clear responsibility boundary between library authors and users.
leandrodamascena commentedon Jan 22, 2025
Hi @lbustelo! Thanks for opening this issue. I'm not very happy with the name of the
idempotency_key_custom_prefixparameter and I think we can find a better one.I agree with letting the customer decide what they want as a prefix and not making assumptions here.
PR: #5898
The experience might be like:
Decorating standalone functions
Decorating the Lambda handler
leandrodamascena commentedon Jan 23, 2025
On second thought, it doesn't make much sense to add
idempotency_keyto the parameter name, it's implicit that this is part of the idempotency mechanism. I'm refactoring to call the parameter askey_prefix.github-actions commentedon Jan 23, 2025
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 tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
github-actions commentedon Jan 28, 2025
This is now released under 3.5.0 version!