Description
Expected Behaviour
The IdempotencyHandler should throw a IdempotencyValidationError
when the validation hash in DynamoDB does not match the incoming event's validation hash (specified by payloadValidationJmesPath
).
Current Behaviour
It does not do that.
Code snippet
I would not expect the example code to work: https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/idempotency/#payload-validation
Steps to Reproduce
- Specify
payloadValidationJmesPath
in theIdempotencyConfig
- Run the same payload twice (except with a difference at the field specified at
payloadValidationJmesPath
No IdempotencyValidationError
will be thrown.
Possible Solution
Reverting to 1.17 fixes the issue.
The changes done in this PR #1779 does not do payload hash checking on the returned document, because that logic is short circuited when returning the existingRecord
on the error.
powertools-lambda-typescript/packages/idempotency/src/IdempotencyHandler.ts
Lines 316 to 320 in 7715df8
The following logic within BasePersistenceLayer.getRecord()
is skipped, so the IdempotencyValidationError
error is not thrown.
Not sure how stable the interface for BaseIdempotencyLayer
is but exposing validatePayload
(and also saveToCache
, because local caching is also being skipped) as protected
and calling that on the returned record would solve the immediate problem but it doesn't seem like the most elegant solution.
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
18.x
Packaging format used
npm
Execution logs
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status