I've been running my Lambda function using NodeJS 22.x in the us-west-2 region, and it's recently started failing to add new items to my DynamoDB table. The error I'm getting is: "One or more parameter values were invalid: Type mismatch for key pk expected: S actual: M." This error doesn't occur consistently, as it sometimes works when I try to insert a few items at a time. But when I attempt to insert around 2000 items with about 10 concurrent requests, it fails randomly for certain items. I've also noticed that everything works well when I run it locally. I'm using the DynamoDBDocumentClient for the insert operation. My primary key (pk) is formatted correctly as a string. Is there a chance that this problem is on AWS's side, or is there something else that could be causing it?
4 Answers
Could it be that your requests are being throttled? If you're using on-demand provisioning, that might not apply, but it's worth checking out the throttling documentation to see if it helps. Sometimes, throttling results in different errors, but this could be part of the problem if you're making many concurrent requests.
You might want to look closely at your input data. The error suggests that for one of your records, the pk is being interpreted as an object instead of a string. It's important to ensure that your data is formatted correctly. Also, consider implementing a queue before inserting into DynamoDB to help manage failed records.
Have you checked the GitHub page for the DynamoDB Document SDK? There might be some known issues or guidance there that could help you troubleshoot further.
Just a quick question—are you using SDK v3 for your NodeJS code? It might make a difference.
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically