@aws-sdk/lib-dynamodb incorrectly marshalls non-object types
See original GitHub issueDescribe the bug
QueryCommandInput AttributeValueList
is not marshaled correctly and the query
command gives me this error:
{
"error": {
"name": "ValidationException",
"message": "One or more parameter values were invalid: Invalid number of argument(s) for the EQ ComparisonOperator",
"callstack": "ValidationException: One or more parameter values were invalid: Invalid number of argument(s) for the EQ ComparisonOperator\n' +
' at deserializeAws_json1_0QueryCommandError (/Users/abuzhinsky/Projects/work/yaft/packages/feature-sync/node_modules/@aws-sdk/client-dynamodb/dist/cjs/protocols/Aws_json1_0.js: 2984: 41)\n' +
' at processTicksAndRejections (internal/process/task_queues.js: 97: 5)\n' +
' at async /Users/abuzhinsky/Projects/work/yaft/packages/feature-sync/node_modules/@aws-sdk/middleware-serde/dist/cjs/deserializerMiddleware.js: 6: 20\n' +
' at async /Users/abuzhinsky/Projects/work/yaft/packages/feature-sync/node_modules/@aws-sdk/middleware-signing/dist/cjs/middleware.js: 11: 20\n' +
' at async StandardRetryStrategy.retry (/Users/abuzhinsky/Projects/work/yaft/packages/feature-sync/node_modules/@aws-sdk/middleware-retry/dist/cjs/StandardRetryStrategy.js: 51: 46)\n' +
' at async /Users/abuzhinsky/Projects/work/yaft/packages/feature-sync/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js: 6: 22\n' +
' at async /Users/abuzhinsky/Projects/work/yaft/packages/feature-sync/node_modules/@aws-sdk/lib-dynamodb/dist/cjs/commands/QueryCommand.js: 44: 26\n' +
' at async /Users/abuzhinsky/Projects/work/yaft/packages/feature-sync/bin/index.js: 26: 21"
}
}
Looks like the problem is located here - the marshall
function expects only the MMember AttributeValue
from the convertToAttr
function.
Your environment
MacOS 11.6, Node 12
SDK version number
@aws-sdk/lib-dynamodb@3.33.0
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the browser/Node.js/ReactNative version
v12.22.6
Steps to reproduce
const docClient = DynamoDBDocument.from(client)
const res = await docClient.query({
TableName: 'TestTable',
KeyConditions: {
id: {
AttributeValueList: ['test'],
ComparisonOperator: 'EQ'
}
}
})
Observed behavior
The command input is marshaled incorrectly and the error is thrown:
{
"TableName": "TestTable",
"KeyConditions": {
"id": {
"AttributeValueList": [
null
],
"ComparisonOperator": "EQ"
}
}
}
Expected behavior
Expected marshaled command input is and query
command should not throw an error:
{
"TableName": "TestTable",
"KeyConditions": {
"id": {
"AttributeValueList": [
{
"S": "test"
}
],
"ComparisonOperator": "EQ"
}
}
}
Additional context
Add any other context about the problem here.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:7
Top Results From Across the Web
@aws-sdk/util-dynamodb | AWS SDK for JavaScript v3
Convert a DynamoDB AttributeValue object to its equivalent JavaScript type. Parameters. data: AttributeValue. The DynamoDB record to convert to JavaScript type.
Read more >@aws-sdk/lib-dynamodb | AWS SDK for JavaScript v3
JavaScript objects passed in as parameters are marshalled into AttributeValue shapes required by Amazon DynamoDB. Responses from DynamoDB are unmarshalled into ...
Read more >Module: AWS.DynamoDB.Converter — AWS SDK for JavaScript
Convert a JavaScript value to its equivalent DynamoDB AttributeValue type. marshall(data, options) ⇒ map. Convert a JavaScript object into a DynamoDB ...
Read more >Using the DynamoDB Document Client - AWS SDK for ...
The DynamoDB Document client simplifies working with items by abstracting the notion of attribute values. This abstraction annotates native JavaScript types ...
Read more >Error handling with DynamoDB - AWS Documentation
If you are not using an AWS SDK, you need to parse the content of the low-level response from ... a value that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@alesso-x that is exactly the bug–
ExecuteStatementCommand
onlib-dynamodb
is just broken until it gets fixed. As a workaround, I ended up usingclient-dynamodb
’s version along withmarshall
/unmarshall
fromutil-dynamodb
.I’m having a similar issue with using
ExecuteStatementCommand
. When I try to pass in parameters, I receive the following errorcode:
if I import
ExecuteStatementCommand
from@aws-sdk/client-dynamodb
then it worksAm I using
ExecuteStatementCommand
incorrectly? I’m assuming if I’m using the version fromlib-dynamodb
, I do not have to create JavaScript objects with theAttributeValue
.