Search code examples
node.jsgoogle-cloud-datastore

Error Message : InvalidKey: A key should contain at least a kind


I am getting following error while trying to update the entity in google cloud datastore:

InvalidKey: A key should contain at least a kind.
    at keyToKeyProto (/Volumes/Drive B/dev/zapi/node_modules/@google-cloud/datastore/src/entity.js:696:11)
    at Array.map (<anonymous>)
    at DatastoreRequest.createReadStream (/Volumes/Drive B/dev/zapi/node_modules/@google-cloud/datastore/src/request.js:226:23)
    at DatastoreRequest.get (/Volumes/Drive B/dev/zapi/node_modules/@google-cloud/datastore/src/request.js:461:8)
    at /Volumes/Drive B/dev/zapi/node_modules/@google-cloud/common/build/src/util.js:681:32
    at new Promise (<anonymous>)
    at Datastore.wrapper [as get] (/Volumes/Drive B/dev/zapi/node_modules/@google-cloud/common/build/src/util.js:662:20)
    at fetchEntity (/Volumes/Drive B/dev/zapi/node_modules/gstore-node/lib/model.js:204:36)
    at Function.get (/Volumes/Drive B/dev/zapi/node_modules/gstore-node/lib/model.js:174:16)
    at Promise (/Volumes/Drive B/dev/zapi/node_modules/gstore-node/lib/utils.js:39:35)
    at new Promise (<anonymous>)
    at Function.wrapper (/Volumes/Drive B/dev/zapi/node_modules/gstore-node/lib/utils.js:27:16)
    at resolve (/Volumes/Drive B/dev/zapi/graphql/mutations/user/linkConsult.js:101:44)

I don't know why is this coming for.

Thanks in advance.


Solution

  • When you trying to access key and key is not available when no data available, it gives the error

    "Error Message : InvalidKey: A key should contain at least a kind"

    To avoid this error first make sure that [datastrore.KEY] is available.

    Thanks