Skip to content

ExpressionAttributeValues in UpdateItemCommand TS Error #2652

@nazarvovk

Description

@nazarvovk

Describe the bug

Incorrect type on ExpressionAttributeValues or UpdateItemCommand not unmarshalling ExpressionAttributeValues properly.

Your environment

Lambda NODEJS_14_X

SDK version number

@aws-cdk/aws-dynamodb@1.117.0

Is the issue in the browser/Node.js/ReactNative?

Node.js

Steps to reproduce

If you pass marshalled values to ExpressionAttributeValues, it inserts them like maps
E.g.:

const command = new UpdateItemCommand({
  TableName: this.tableName,
  Key: marshall({
    PK: `CANDLESTICK#${candlestick.symbol}`,
    SK: candlestick.persistenceKey,
  }),
  UpdateExpression, // this is in form "set #key_test1 = :test1, #key_test2 = :test2"
  ExpressionAttributeValues: marshall(attributeValues), // attributeValues is of type Record<string, string>.
  ExpressionAttributeNames: attributeNames,
})

pic

If you do it like that, it inserts the values correctly, but there's a ts error, it expects marshalled values:

const command = new UpdateItemCommand({
  TableName: this.tableName,
  Key: marshall({
    PK: `CANDLESTICK#${candlestick.symbol}`,
    SK: candlestick.persistenceKey,
  }),
  UpdateExpression,
  ExpressionAttributeValues: attributeValues, // Error here
  ExpressionAttributeNames: attributeNames,
})

pic

The problem is only with ExpressionAttributeValues, ExpressionAttributeNames already accepts { [key: string]: string } and works fine

Expected behavior

Either ExpressionAttributeValues needs to expect a type of { [key: string]: string }, or should unmarshall the values to properly insert into the db

Metadata

Metadata

Assignees

Labels

guidanceGeneral information and guidance, answers to FAQs, or recommended best practices/resources.response-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions