在这个坑上,经历了两次,所以我不得不写篇文章记录一下。起先是因为我只定义了一个 schema:
KeySchema:
- AttributeName: id
KeyType: HASH
后来,变成了两个:
KeySchema:
- AttributeName: id
KeyType: HASH
- AttributeName: token
KeyType: RANGE
结果在对应的查询参数的 Key 里,漏掉了这部分的内容:
Key: {
id: body.id
},
导致了:
{ ValidationException: The provided key element does not match the schema
at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:48:27)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
message: 'The provided key element does not match the schema',
code: 'ValidationException',
time: 2019-02-26T12:31:25.507Z,
requestId: 'POTAMPSSPFSOIU78QM637HK7BNVV4KQNSO5AEMVJF66Q9ASUAAJG',
statusCode: 400,
retryable: false,
retryDelay: 44.331159666822884 } null
END RequestId: 782c2eb3-629e-43e0-b63c-c66678c5590b
下次,记得,加上,加上:
Key: {
id: body.id,
token: body.token // 缺少了这部分的内容
},
围观我的Github Idea墙, 也许,你会遇到心仪的项目