Skip to content

DynamoDB Document client - DELETE operation not working #291

@IkKan

Description

@IkKan

This is a Bug Report

Description

  • Adding #LambdaPowertoolsContext in Document client query on DELETE stringset item results with query being malformed.*
  • Steps to reproduce:
      const DynamoDB = require('@dazn/lambda-powertools-dynamodb-client')
       let teamSet = DynamoDB.createSet([teamId])
       try {

          let result = await DynamoDB.update({
            TableName: userTableName,
            Key: {
              accountId: accountId,  
              id: userId
            },
            UpdateExpression: "DELETE #memberOf :t",
            ExpressionAttributeNames: {
              "#memberOf" : "memberOf"
            },
            ExpressionAttributeValues: {
                ":t" : teamSet
            },  
            ReturnValues: "UPDATED_NEW"
          }).promise();

        console.log(result)
        } catch(err){
          Log.error('Caught error while updating', {}, err);
          throw Error('Update operation has failed');
        } 
  • Error received:
    {"message":"Invalid UpdateExpression: Syntax error; token: \"undefined\", near: \":t undefined SET\"","code":"ValidationException"}
  • Debug log

Serverless: [AWS dynamodb 400 0.181s 0 retries] updateItem({
TableName: 'XC_Users',
Key: {
accountId: { S: '8500fe56-d136-496c-ba51-12d40bac1f8c' },
id: { S: 'd1412d82-b234-4cbf-a814-81fe29daaf05' }
},
UpdateExpression: 'DELETE #memberOf :t undefined SET #LambdaPowertoolsContext = :LambdaPowertoolsContext',
ExpressionAttributeNames: {
'#memberOf': 'memberOf',
'#LambdaPowertoolsContext': 'context'
},
ExpressionAttributeValues: {
':t': { SS: [ '53e003b6-d907-404d-bc6e-aa4b9ed2b7ef', [length]: 1 ] },
':LambdaPowertoolsContext': {
M: {
'x-correlation-id': { S: '1ec7a9c8-6860-4501-80a8-cc0c5f59b30b' },
awsRequestId: { S: '1ec7a9c8-6860-4501-80a8-cc0c5f59b30b' },
'debug-log-enabled': { S: 'true' }
}
}
},
ReturnValues: 'UPDATED_NEW'
})

Additional Data

  • Which powertool package are you using?: @dazn/lambda-powertools-dynamodb-client
  • Which version are you using?: 1.28.1
  • Middy engine version you're using: 2.5.3
  • Operating System: Fedora 35 / AWS Lamda nodejs14.x
  • Stack Trace:
  • Provider Error messages:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions