- Newest
- Most votes
- Most comments
This one looks like a client-side serialization problem rather than anything that changed on the DynamoDB side. Two things in the error give it away: the '$fault': 'client' with a 400 status, and the stack trace going through AwsJson1_0Protocol.handleError and the @smithy/core schema/protocol serializer. So the request never really reached DynamoDB in a valid form — the SDK couldn't serialize it and bailed out first. That's also why you didn't get any service notification.
The message Start of structure or map found where not expected basically means the serializer hit an object/map somewhere it expected a different type, most often a list.
Since nothing changed in your own code, I'd start by checking the SDK version. The managed Node.js runtimes ship their own copy of the v3 SDK, and that version gets bumped over time as AWS updates the runtime. The newer serializer is stricter about request shapes, so something that used to go through can now throw SerializationException. I can't say for certain that's what happened here, but comparing the SDK version in your function now vs. before should tell you pretty quickly.
The usual causes for this particular error:
- Mixing marshalled and unmarshalled input — e.g. sending already-marshalled values like
{ S: "value" }intoDynamoDBDocumentClient, or sending plain objects to the low-levelDynamoDBClientwithoutmarshall(). Best to stick to one. - A field that should be a list being passed as an object (or the reverse).
undefinedor empty values sneaking intoItem,Key, orExpressionAttributeValues.
A couple of things that tend to help: log the exact params going into the command and diff them against the API reference field by field, and consider bundling @aws-sdk/client-dynamodb and @aws-sdk/lib-dynamodb in your package (or a layer) and pinning them in package.json so the runtime's SDK version isn't controlling behavior for you.
Some references:
@aws-sdk/lib-dynamodb(Document Client): https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-lib-dynamodb/- Managing dependencies in the Lambda Node.js runtime: https://docs.aws.amazon.com/lambda/latest/dg/nodejs-package.html
The SerializationException error you're encountering typically indicates a data format mismatch when your Lambda function is attempting to write to or read from DynamoDB. This error occurs when the data structure being sent doesn't match what DynamoDB expects.
Common causes for this issue include:
-
Incorrect data type formatting: DynamoDB requires items to be formatted with explicit type descriptors (e.g., {'S': 'string_value'} for strings, {'N': 'number_value'} for numbers). If you're sending plain JavaScript objects without these type descriptors, you'll encounter serialization errors.
-
Malformed item structure: The item being written may contain nested structures or data types that aren't properly formatted for DynamoDB's expected schema.
-
SDK version or code changes: If there were recent updates to your Lambda function code or dependencies, there may have been unintentional changes to how data is being structured before sending to DynamoDB.
To troubleshoot this issue:
- Review your Lambda function code to ensure all DynamoDB operations are formatting data correctly with proper type descriptors
- Verify that any data transformations or JSON parsing are producing the expected structure
- Check if there were any recent deployments or code changes to your Lambda functions
- Add logging to capture the exact data structure being sent to DynamoDB before the put_item or update_item call
- Ensure your Lambda function has the necessary IAM permissions to interact with DynamoDB
If you need further assistance with your specific case, please add correspondence through the AWS Support Center at https://console.aws.amazon.com/support/ with additional details about your Lambda function code and the specific DynamoDB operations being performed.
Sources
Using Lambda functions in AWS SAM and Infrastructure Composer - AWS Lambda
Relevant content
asked 21 days ago
asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
