-
Notifications
You must be signed in to change notification settings - Fork 646
Closed
Labels
bugThis issue is a bug.This issue is a bug.
Description
Describe the bug
When unmarshalling very small numbers like 0.0000001 from a DynamoDB table, an unexpected Error is thrown.
Your environment
SDK version number
@aws-sdk/util-dynamodb@3.4.0
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the browser/Node.js/ReactNative version
Node.js version v12.20.1
Steps to reproduce
- Start with an object containing javascript Number, e.g.
{score: 0.0000001} - Marshall this object using
util-dynamodb, then store in a DynamoDB table usingclient-dynamodb - Retrieve the record from the table and umarshall it
Observed behavior
When attempting to unmarshall the record, an Error is thrown with the following message:
UnhandledPromiseRejectionWarning: Error: Value 0.0000001 is outside IEEE 754 Floating-Point Arithmetic. Set options.wrapNumbers to get string value.
Expected behavior
The unmarshalling should complete without error.
Sample code
Hopefully this code illustrates the issue:
import { DynamoDB } from '@aws-sdk/client-dynamodb';
import { marshall, unmarshall } from '@aws-sdk/util-dynamodb';
async function doTest(): Promise<void> {
const tableName = 'my-table';
const client = new DynamoDB({ region: 'eu-west-1' });
const data = {
Id: 'test-id',
Timestamp: Date.now(),
data: { score: 0.0000001 }
};
await client.putItem({
TableName: tableName,
Item: marshall(data)
});
const record = await client.query({
TableName: tableName,
KeyConditionExpression: 'Id = :id',
ExpressionAttributeValues: marshall({
':id': 'test-id'
})
});
unmarshall(record.Items[0]);
}
void doTest();Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.