Confirm by changing [ ] to [x] below to ensure that it's a bug:
Describe the bug
The bug should loosely be called a bug, or perhaps a feature request. In the function convertInput in the aws-sdk lib dynamodb converter.js it does not support BigInt data types. As of Node 10.x being supported with Lambdas, the BigInt data type is available to us in Node. The problem is simply, typeof(BigInt) does not evaluate to Number, or NumberValue. Instead it evaluates to 'bigint'.
Is the issue in the browser/Node.js?
Node JS for the aws-sdk > dynamodb > converter.js
If on Node.js, are you running this on AWS Lambda?
Yes
Details of the browser/Node.js version
Node 10.x
SDK version number
AWS Lambda 10.x
To Reproduce (observed behavior)
Try to store a BigInt data type from params using any of the aws-sdk dynmodb document client write functions. You'll notice that the error states that it cannot parse an M. this is because the converter default is to try to cast it to a map rather than evaluating bigint as a number.
Expected behavior
Have the converter function cast bigint to N data type as defined by the documentation.
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.DataTypes.html
Hey @TechTeam12, thank-you for reaching out to us with your issue.
I agree with you that it is more like a feature request so I will mark it as a feature request.
I see you also have a PR for it, I will review it and test it and would be happy to merge it if it doesn't break anything.
Hey @ajredniwja,
Thanks for following it up. I marked it as a bug report since AWS Lambda Node 10 support BigInt officially, but the SDK does not. That was my logic, I figured if you're running tests for Node 10 and AWS supports Node 10 it was probably a miss when adding the node version support.
Either way, let me know if there is more I can do to help. Definitely need this functionality ASAP.
Thanks,
Released in v2.610.0 https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md#26100
@TechTeam12 Please verify and close this issue
This commit has since been reversed: https://github.com/aws/aws-sdk-js/commit/5155fde557ecc1d166bb5040823289254bea1641# as a result of https://github.com/aws/aws-sdk-js/issues/3246
So now there appears to be no way to store or retrieve numbers larger than 2^53 (Number.MAX_SAFE_INTEGER) in DynamoDB, and we are in the same spot as when this issue was first opened. Is there a planned resolution path?
We've published Release Candidate for AWS SDK for JavaScript v3.
As part of the RC release, we've published utility functions for marshall and unmarshall operations in @aws-sdk/util-dynamodb which supports BigInt conversion. These utility functions can also be used with v2 as follows:
const AWS = require("aws-sdk");
const { marshall, unmarshall } = require("@aws-sdk/util-dynamodb");
const client = new AWS.DynamoDB(clientParams);
const putParams = {
TableName: "Table",
Item: marshall({
HashKey: "hashKey",
BigIntAttribute: 1n,
}),
};
await client.putItem(putParams).promise();
const getParams = {
TableName: "Table",
Key: marshall({
HashKey: "hashKey",
}),
};
const { Item } = await client.getItem(getParams);
unmarshall(Item);
Is there any way to use this marshalling with the DynamoDB DocumentClient?
Whoa I see, it looks like the DocumentClient has been completely removed from the aws-sdk-js-v3?
Update: it would appear so https://github.com/aws/aws-sdk-js-v3/issues/1677
Most helpful comment
We've published Release Candidate for AWS SDK for JavaScript v3.
As part of the RC release, we've published utility functions for marshall and unmarshall operations in @aws-sdk/util-dynamodb which supports BigInt conversion. These utility functions can also be used with v2 as follows: