Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

276
Vistas
NUMBER_VALUE cannot be converted to String when updating Item

I have this strange issue with DynamoDB where I cannot seem to update an item.

Here is my command:

TableName: 'UserTable',
Key: { UID: { S: 'h4XJj3YRxZiF7TDcGkxAhc' } },
UpdateExpression: 'SET numRatings = :numRatings',
ExpressionAttributeValues: { ':numRatings': { N: 336 } },
ReturnValues: 'UPDATED_NEW'

I have verified that the table is correct, and that the key of the table UID does indeed have the hash h4XJj3YRxZiF7TDcGkxAhc as a value. numRatings currently is equal to 1.

Here's my code:

  const params = {
    TableName: process.env.USER_TABLE_NAME!,
    Key: {
      UID: {
        S: UID
      }
    },
    UpdateExpression: 'SET numRatings = :numRatings',
    ExpressionAttributeValues: {
      ':numRatings': { N: numRatings } as unknown as AttributeValue
    },
    ReturnValues: 'UPDATED_NEW'
  } as UpdateItemCommandInput;

  try {
    const result = await dbClient.send(new UpdateItemCommand(params));
...

Yet I get this error: NUMBER_VALUE cannot be converted to String maybe I am blind but I cannot see where this conversion could be taking place.

I am using TypeScript and AWS-SDK 3.54.0

If anyone is able to point out what I am doing wrong I would greatly appreciate it.

Item

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Per the AttributeValue documentation:

Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and libraries. However, DynamoDB treats them as number type attributes for mathematical operations.

So you need to send numeric values as type N but the value is a string:

':numRatings': { N: `${numRatings}` }
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda