AWS DynamoDB 报错:The provided key element does not match the schema

栏目: 数据库 · 发布时间: 5年前

内容简介:在这个坑上,经历了两次,所以我不得不写篇文章记录一下。起先是因为我只定义了一个 schema:后来,变成了两个:结果在对应的查询参数的 Key 里,漏掉了这部分的内容:

在这个坑上,经历了两次,所以我不得不写篇文章记录一下。起先是因为我只定义了一个 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  // 缺少了这部分的内容
  },

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Pro Git (Second Edition)

Pro Git (Second Edition)

Scott Chacon、Ben Straub / Apress / 2014-11-9 / USD 59.99

Scott Chacon is a cofounder and the CIO of GitHub and is also the maintainer of the Git homepage ( git-scm.com ) . Scott has presented at dozens of conferences around the world on Git, GitHub and the ......一起来看看 《Pro Git (Second Edition)》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码