-
Notifications
You must be signed in to change notification settings - Fork 180
Description
Expected Behavior
Successful idempotency write of successful request.
Current Behavior
After a successful write to the DynamoDB table for the idempotency record, once the handler has successfully executed with no errors thrown, it then throws the below error as the last log line of the execution.
It does successfully run the DeleteItemCommand hust before throwing this error and have verified with setting the dynamoDB client with a logger.
{
"errorType": "IdempotencyPersistenceLayerError",
"errorMessage": "Failed to update success record to idempotency store",
"name": "IdempotencyPersistenceLayerError",
"stack": [
"IdempotencyPersistenceLayerError: Failed to update success record to idempotency store",
" at #saveSuccessfullResult (/var/task/handler.js:210624:13)",
" at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
" at async IdempotencyHandler.handleMiddyAfter (/var/task/handler.js:210554:5)",
" at async after (/var/task/handler.js:210922:5)",
" at async runMiddlewares (/var/task/handler.js:202652:17)",
" at async runRequest (/var/task/handler.js:202627:7)"
]
}
Code snippet
I'm using a HTTP V2 lambda event, expecting to use an idempotency key of the header of header."idempotency-key". This seems to work.
import { IdempotencyConfig } from '@aws-lambda-powertools/idempotency';
import { DynamoDBPersistenceLayer } from '@aws-lambda-powertools/idempotency/dynamodb';
export const idempotencyPersistenceStore = new DynamoDBPersistenceLayer({
tableName: 'idempotencyTable',
clientConfig: {
region: 'eu-west-1',
logger: console,
},
});
export const idempotencyConfig = new IdempotencyConfig({
expiresAfterSeconds: 60 * 60 * 24, // 1 day
eventKeyJmesPath: 'headers."idempotency-key"',
throwOnNoIdempotencyKey: false,
});
export const create = middy(lambdaHandler)
.use(inputOutputLogger({ logger: (request) => logger.info(request) }))
.use(
makeHandlerIdempotent({
persistenceStore: idempotencyPersistenceStore,
config: idempotencyConfig,
}),
)
Steps to Reproduce
Use code snippet above
Possible Solution
Tried many different variations of the config and implementation and continuously the same error.
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
20.x
Packaging format used
npm
Execution logs
Initial write is successful:
{
clientName: 'DynamoDBClient',
commandName: 'PutItemCommand',
input: {
TableName: 'idempotencyTable',
Item: {
id: [Object],
expiration: [Object],
status: [Object],
in_progress_expiration: [Object]
},
ExpressionAttributeNames: {
'#id': 'id',
'#expiry': 'expiration',
'#in_progress_expiry': 'in_progress_expiration',
'#status': 'status'
},
ExpressionAttributeValues: {
':now': [Object],
':now_in_millis': [Object],
':inprogress': [Object]
},
ConditionExpression: 'attribute_not_exists(#id) OR #expiry < :now OR (#status = :inprogress AND attribute_exists(#in_progress_expiry) AND #in_progress_expiry < :now_in_millis)',
ReturnValuesOnConditionCheckFailure: 'ALL_OLD'
},
output: {},
metadata: {
httpStatusCode: 200,
requestId: '5OIR7F73V0MVF2HDRCV9JOPS9NVV4KQNSO5AEMVJF66Q9ASUAAJG',
extendedRequestId: undefined,
cfId: undefined,
attempts: 1,
totalRetryDelay: 0
}
}My code continues to execute and is successfully returning a HTTP V2 response of { statusCode: 200, JSON.stringify({ result: true}) }
{
clientName: 'DynamoDBClient',
commandName: 'DeleteItemCommand',
input: {
TableName: 'idempotencyTable',
Key: { id: [Object] }
},
output: {},
metadata: {
httpStatusCode: 200,
requestId: 'EIM7659KJ9JBD9ABUIKJBDT567VV4KQNSO5AEMVJF66Q9ASUAAJG',
extendedRequestId: undefined,
cfId: undefined,
attempts: 1,
totalRetryDelay: 0
}
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status