-
Notifications
You must be signed in to change notification settings - Fork 98
Description
Expected Behaviour
When enabling JMESPath payload validation in the Idempotency utility (https://docs.aws.amazon.com/powertools/java/latest/utilities/idempotency/#payload-validation) I expect that an IdempotencyValidationException is thrown when the expected field does not match the value of the cached field for this idempotency key.
Current Behaviour
This exception is not thrown in all cases anymore after introducing an optimization to save DynamoDB calls in PR #1821.
We are optimistically calling the putRecord operation and if this fails because the key already exists we return the payload instead of making another getRecord call. For this specific case, we are missing to validate the payload and never raise a the IdempotencyValidationException.
Lines 232 to 238 in 71c632b
| if (e.hasItem()) { | |
| DataRecord existingRecord = itemToRecord(e.item()); | |
| throw new IdempotencyItemAlreadyExistsException( | |
| "Failed to put record for already existing idempotency key: " + record.getIdempotencyKey() | |
| + ". Existing record: " + existingRecord, | |
| e, existingRecord); | |
| } |
Code snippet
N/APossible Solution
Add payload validation to a catch block in BasePersistenceStore.java.
Steps to Reproduce
Enable payload validation and send two payloads with different fields for the same idempotency key.
Powertools for AWS Lambda (Java) version
latest
AWS Lambda function runtime
Java 21
Debugging logs
Metadata
Metadata
Assignees
Labels
Type
Projects
Status