Skip to content
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

DynamoDB Document client - DELETE operation not working #291

Open
IkKan opened this issue Dec 14, 2021 · 0 comments
Open

DynamoDB Document client - DELETE operation not working #291

IkKan opened this issue Dec 14, 2021 · 0 comments

Comments

@IkKan
Copy link

IkKan commented Dec 14, 2021

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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant