Bird
0
0

You wrote this code to put an item but it fails with a validation error:

medium📝 Debug Q6 of 15
AWS - DynamoDB
You wrote this code to put an item but it fails with a validation error:
const params = { TableName: 'Orders', Item: { OrderId: '123', Amount: 50 } };
await client.put(params);

What is the likely cause?
AItem attributes must be wrapped with DynamoDB types like { S: '123' }
BTableName is incorrect
CPut operation requires a Key parameter
DAmount cannot be a number
Step-by-Step Solution
Solution:
  1. Step 1: Check item attribute format

    DynamoDB expects attribute values wrapped with type descriptors like { S: 'string' } or { N: 'number' }.
  2. Step 2: Identify missing type wrappers

    The code uses raw values without type wrappers, causing validation error.
  3. Final Answer:

    Item attributes must be wrapped with DynamoDB types like { S: '123' } -> Option A
  4. Quick Check:

    Put item values need type wrappers [OK]
Quick Trick: Wrap item values with DynamoDB types like { S: 'text' } [OK]
Common Mistakes:
  • Using raw values without type wrappers
  • Confusing Key with Item
  • Wrong TableName causes different error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes