title: DynamoDB update - "ValidationException: An operand in the update expression has an incorrect data type"
body: <p>I am trying to append to a string set (array of strings) column, which may or may not already exist, in a DynamoDB table. I referred to SO questions like <a href="https://stackoverflow.com/a/41402470/11249670">this</a> and <a href="https://stackoverflow.com/a/41402470/11249670">this</a> when writing my UpdateExpression.</p>
  
  <p>My code looks like this.</p>
  
  <pre class="lang-js prettyprint-override"><code>const AWS = require('aws-sdk')
  const dynamo = new AWS.DynamoDB.DocumentClient()
  
  const updateParams = {
      // The table definitely exists.
      TableName: process.env.DYNAMO_TABLE_NAME,
      Key: {
        email: user.email
      },
      // The column may or may not exist, which is why I am combining list_append with if_not_exists.
      UpdateExpression: 'SET #column = list_append(if_not_exists(#column, :empty_list), :vals)',
      ExpressionAttributeNames: {
        '#column': 'items'
      },
      ExpressionAttributeValues: {
        ':vals': ['test', 'test2'],
        ':empty_list': []
      },
      ReturnValues: 'UPDATED_NEW'
  }
  
  dynamo.update(updateParams).promise().catch((error) =&gt; {
      console.log(`Error: ${error}`)
  })
  
  </code></pre>
  
  <p>However, I am getting this error: <code>ValidationException: An operand in the update expression has an incorrect data type</code>. What am I doing incorrectly here?</p>
  
  <hr>
  
  <p><strong>[Update]</strong>
  Thanks to Nadav Har'El's answer, I was able to make it work by amending the params to use the <code>ADD</code> operation instead of <code>SET</code>.</p>
  
  <pre class="lang-js prettyprint-override"><code>const updateParams = {
      TableName: process.env.DYNAMO_TABLE_NAME,
      Key: {
        email: user.email
      },
      UpdateExpression: 'ADD items :vals',
      ExpressionAttributeValues: {
        ':vals': dynamo.createSet(['test', 'test2'])
      }
  }
  </code></pre>