You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the case a moveParameterNames is called, and there is more than 9 filters in the query, the regex on line object.ExpressionAttributeValues[key.replace(new RegExp(":v\\d"), `:${prefix}v`)] = object.ExpressionAttributeValues[key]; become invalid, because there is more than one digit in the parameter index. The whole number must be replaced.
Code sample:
Schema
Anything having a sort key
Current output and behavior (including stack trace):
"FilterExpression": "NOT contains (#a1, :v1) AND NOT contains (#a2, :v2) AND NOT contains (#a3, :v3) AND NOT contains (#a4, :v4) AND NOT contains (#a5, :v5) AND NOT contains (#a6, :v6) AND NOT contains (#a7, :v7) AND NOT contains (#a8, :v8) AND NOT contains (#a9, :v9) AND NOT contains (#a10, :v10)",
"ExpressionAttributeNames": {
"#a1": "step",
"#a2": "step",
"#a3": "step",
"#a4": "step",
"#a5": "step",
"#a6": "step",
"#a7": "step",
"#a8": "step",
"#a9": "step",
"#a10": "step",
"#qha": "user",
"#qra": "createdAt"
},
"ExpressionAttributeValues": {
":v1": {
"S": "someValue1"
},
":v2": {
"S": "someValue2"
},
":v3": {
"S": "someValue3"
},
":v4": {
"S": "someValue4"
},
":v5": {
"S": "someValue5"
},
":v6": {
"S": "someValue6"
},
":v7": {
"S": "someValue7"
},
":v8": {
"S": "someValue8"
},
":v9": {
"S": "someValue9"
},
":v10": {
"S": "someValue10"
},
":qhv": {
"S": "360"
},
":qrv1": {
"N": "1672575150000"
}
},
"TableName": "myTable",
"IndexName": "myTable-createdAt-index",
"KeyConditionExpression": "#qha = :qhv AND #qra >= :qrv",
"ScanIndexForward": false
}
Note the createdAt ExpressionAttributeValues is ':qrv1'. It used to be :v11 but the regex only replaced the first '1'. In KeyConditionExpression, it is properly written as ':qrv'
Here's the stack :
ValidationException: Invalid KeyConditionExpression: An expression attribute value used in expression is not defined; attribute value: :qrv
at throwDefaultError (/thepathtomyproject/node_modules/@aws-sdk/smithy-client/dist-cjs/default-error-handler.js:8:22)
at de_QueryCommandError (/thepathtomyproject/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:2140:51)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /thepathtomyproject/node_modules/@aws-sdk/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24
at async /thepathtomyproject/node_modules/@aws-sdk/middleware-signing/dist-cjs/middleware.js:14:20
at async /thepathtomyproject/node_modules/@aws-sdk/middleware-retry/dist-cjs/retryMiddleware.js:27:46
at async /thepathtomyproject/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26
at async main (/thepathtomyproject/node_modules/dynamoose/dist/aws/ddb/internal.js:6:20)
at async /thepathtomyproject/node_modules/dynamoose/dist/ItemRetriever.js:105:32
at async getProcessesV2 (file:///thepathtomyproject/src/controller/user.js:242:25)
Expected output and behavior:
In ExpressionAttributeValues, the regex should remove every digit of the attribute index. It should be ':qrv'.
"FilterExpression": "NOT contains (#a1, :v1) AND NOT contains (#a2, :v2) AND NOT contains (#a3, :v3) AND NOT contains (#a4, :v4) AND NOT contains (#a5, :v5) AND NOT contains (#a6, :v6) AND NOT contains (#a7, :v7) AND NOT contains (#a8, :v8) AND NOT contains (#a9, :v9) AND NOT contains (#a10, :v10)",
"ExpressionAttributeNames": {
"#a1": "step",
"#a2": "step",
"#a3": "step",
"#a4": "step",
"#a5": "step",
"#a6": "step",
"#a7": "step",
"#a8": "step",
"#a9": "step",
"#a10": "step",
"#qha": "user",
"#qra": "createdAt"
},
"ExpressionAttributeValues": {
":v1": {
"S": "someValue1"
},
":v2": {
"S": "someValue2"
},
":v3": {
"S": "someValue3"
},
":v4": {
"S": "someValue4"
},
":v5": {
"S": "someValue5"
},
":v6": {
"S": "someValue6"
},
":v7": {
"S": "someValue7"
},
":v8": {
"S": "someValue8"
},
":v9": {
"S": "someValue9"
},
":v10": {
"S": "someValue10"
},
":qhv": {
"S": "360"
},
":qrv": {
"N": "1672575150000"
}
},
"TableName": "myTable",
"IndexName": "myTable-createdAt-index",
"KeyConditionExpression": "#qha = :qhv AND #qra >= :qrv",
"ScanIndexForward": false
}
Environment:
Operating System: Ubuntu
Operating System Version: 22.04
Node.js version (node -v): 18.12.1
NPM version: (npm -v): 9.5.0
Dynamoose version: 3.2.1
Other:
I have read through the Dynamoose documentation before posting this issue
I have searched through the GitHub issues (including closed issues) and pull requests to ensure this issue has not already been raised before
I have searched the internet and Stack Overflow to ensure this issue hasn't been raised or answered before
I have tested the code provided and am confident it doesn't work as intended
I have filled out all fields above
I am running the latest version of Dynamoose
The text was updated successfully, but these errors were encountered:
Summary:
In the case a moveParameterNames is called, and there is more than 9 filters in the query, the regex on line
object.ExpressionAttributeValues[key.replace(new RegExp(":v\\d"), `:${prefix}v`)] = object.ExpressionAttributeValues[key];
become invalid, because there is more than one digit in the parameter index. The whole number must be replaced.Code sample:
Schema
Anything having a sort key
Current output and behavior (including stack trace):
Note the createdAt ExpressionAttributeValues is ':qrv1'. It used to be :v11 but the regex only replaced the first '1'. In KeyConditionExpression, it is properly written as ':qrv'
Here's the stack :
Expected output and behavior:
In ExpressionAttributeValues, the regex should remove every digit of the attribute index. It should be ':qrv'.
Environment:
Operating System: Ubuntu
Operating System Version: 22.04
Node.js version (
node -v
): 18.12.1NPM version: (
npm -v
): 9.5.0Dynamoose version: 3.2.1
Other:
The text was updated successfully, but these errors were encountered: