-
Notifications
You must be signed in to change notification settings - Fork 153
Bug: Payload Hash is Not Set on IdempotentRecord When Retrieving from Dynamo & Failing Validation #1499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @brianhyder thank you for reporting the bug. We'll take a look and get back to you in this same thread. |
Hi @brianhyder, I can confirm that I'm able to reproduce the issue and indeed there's a bug in the idempotency record creation upon retrieval. I followed the call stack and like you pointed out, even when the I'm going to run a few more requests and check that no other fields is being dropped as well as adding tests to reduce the risk for future regressions on this topic. After that I'll push a PR. Thanks for taking the time to not only report the issue but also investigate the issue, that was helpful. |
I found also another bug related to this feature: when saving or updating the record with validation enabled we were not using the JMESPath expression provided (the two linked lines should call this function which needs to be updated to match this implementation). With this issue, even keeping in account the As a side note, assuming that your event looks like this: {
"headers": {
"idempotency-key": "1234"
}
} then the JMESPath expression should be |
The PR is up, if you have bandwidth feel free to give it a try - otherwise it'll be merged once @am29d reviews it. |
No worries! I'm happy to help. I'll review the PR this morning. Thank you for the info on the JMES path. |
|
Expected Behaviour
When payload validation is enabled, the idempotency package should retrieve the item from dynamo and create an IdempotentRecord which includes the payload hash.
Current Behaviour
When payload validation is enabled, the idempotency package retrieves the item from dynamo but does not properly set the payload hash on the IdempotentRecord object. When the payload hash from the previous request is compared with the current payload hash, an error is thrown because the hash does not match the retrieved hash (set to undefined).
Code snippet
Configuration:
Offending Code: DynamoDBPersistenceLayer->_getRecord()
https://github.com/awslabs/aws-lambda-powertools-typescript/blob/main/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts#L108
Code that triggers error:
https://github.com/awslabs/aws-lambda-powertools-typescript/blob/main/packages/idempotency/src/persistence/BasePersistenceLayer.ts#L112
Steps to Reproduce
Possible Solution
Update the DynamoDBPersistenceLayer->_getRecord() to include the
validation
attribute value when creating the IdempotentRecord object.Also check to make sure all of the other possible properties are capable of being set.
NOTE: the above was not tested but based on line-by-line debugging.
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
18.x
Packaging format used
npm
Execution logs
The text was updated successfully, but these errors were encountered: