AWS DynamoDB node doesn’t support Field Values that are purely expressions

Describe the problem/error/question

I’m having trouble sending requests to DynamoDB when the Field Value is a purely an expression: {{ $json.id }}

It DOES work if there are other non-expression characters: Item {{ $json.id }}

For reference, I’m able to send primitive values in AWS CLI:

 aws dynamodb put-item \   
    --table-name table-name \
    --item '{"id": {"S": "2416"}' \
    --profile n8n-test

What is the error message (if any)?

I get this error message: AWS error response [undefined]: Bad request - please check your parameters

Please share your workflow

Information on your n8n setup

  • n8n version: 2.4.8

  • Database (default: SQLite): AWS DynamoDB

  • n8n EXECUTIONS_PROCESS setting (default: own, main): Own

  • Running n8n via (Docker, npm, n8n cloud, desktop app): Cloud

  • Operating system: Cloud

As an additional note:

n8n DyanoDB node’s Field Value is treating the sent property as a Number even if it’s a String if it only contains numbers.

Input schema:

idA: String
idB: String

Sample input:

{
  "idA": "2415", // clearly a string
  "idB": "testid" // also a string
}

On DyanoDB node

These are working:

Field Id: id, Field Value: {{ $json.idB }}

Field Id: id, Field Value: testid

Field Id: id, Field Value: Test {{ $json.idA }}

Field Id: id, Field Value: "{{ $json.idA }}"

These wield yield an error:

Field Id: id, Field Value: {{ $json.idA }}

Field Id: id, Field Value: {{ $json.idA.toString() }}

Field Id: id, Field Value: {{ $json.id.trim() }}

Field Id: id, Field Value: {{ String($json.idA) }}

Field Id: id, Field Value: {{ `${$json.idA}` }}

Field Id: id, Field Value: 2415

Is there a way to prevent n8n from doing an automatic type coercion for String with purely numeric characters? My id field in dynamo db needs to accept a string only.

You need to explicitly set the field type in the DynamoDB node. Here’s how:

  1. In your AWS DynamoDB node (“Create or update an item”)

  2. Under Fields to Send → Field Values

  3. Click on the field where you have id

  4. You’ll see Field ID and Field Value

  5. Look for an Options or Additional Options section for that field

  6. Set the Attribute Type to String (or whatever type your id field should be)

Alternative Solution: Use String Concatenation

If the above doesn’t work or you can’t find the type option, force it to be a string by concatenating with an empty string:

={{ $json.trn + '' }}

Or use the String() function:

={{ String($json.trn) }}
1 Like

The (Key - Type - Value) fields exists for GET and DELETE. But the CREATE or UPDATE only has (Field Item - Field Value) fields, with no way to force set a type.

I already tried the following, but they are still coerced into a number by the node itself before sending to DynamoDB, which throws an error:

// Given idA = 2415 // Number
Field Id: id, Field Value: {{ $json.idA }}
Field Id: id, Field Value: {{ $json.idA.toString() }}
Field Id: id, Field Value: {{ $json.id.trim() }}
Field Id: id, Field Value: {{ String($json.idA) }}
Field Id: id, Field Value: {{ `${$json.idA}` }}
Field Id: id, Field Value: 2415
1 Like

I saw this Github issue raised which might be related to it: