-
Notifications
You must be signed in to change notification settings - Fork 161
Closed
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utilityidempotencyThis item relates to the Idempotency UtilityThis item relates to the Idempotency Utility
Milestone
Description
Use case
When using the Idempotency utility, users should be able to enforce that an idempotency key is required. When this requirement is expected and not satisfied, the utility should throw an IdempotencyKeyError
.
Solution/User Experience
The throwOnNoIdempotencyKey
key should be used in conjunction with the eventKeyJmesPath
one:
import { IdempotencyConfig } from '@aws-lambda-powertools/idempotency';
const config = new IdempotencyConfig({
eventKeyJmesPath: '[user.uid, order_id]',
throwOnNoIdempotencyKey: true
});
Given the above, the following event payload will be OK:
{
"user": {
"uid": "BB0D045C-8878-40C8-889E-38B3CB0A61B1",
"name": "Foo"
},
"order_id": 10000
}
while the one below will cause an IdempotencyKeyError
to be thrown (notice :
that order_id
is within the user
key, and so it won't satisfy the JMESPath expression from above)
{
"user": {
"uid": "DE0D000E-1234-10D1-991E-EAC1DD1D52C8",
"name": "Joe Bloggs",
"order_id": 10000
},
}
Alternative solutions
No response
Acknowledgment
- This feature request meets Lambda Powertools Tenets
- Should this be considered in other Lambda Powertools languages? i.e. Python, Java
Metadata
Metadata
Assignees
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utilityidempotencyThis item relates to the Idempotency UtilityThis item relates to the Idempotency Utility