Mutation results in Internal Server Error "Validation Error: data must be object"

Hi all,

I have a local Ceramic Node and ComposeDB set up and working, can execute queries, … it feels like I’m really close to a working app, however, when trying to create a simple Profile, Ceramic is returning an Internal Server Error. I’m using the graphql UI to run the mutation, but getting the same error from the JS API.

My model:

type Profile @createModel(accountRelation: SINGLE, description: "User profile info") {
  name: String! @string(maxLength: 100)
  description: String @string(maxLength: 2000)
  entityType: EntityType
}

enum EntityType {
  PERSON
  ENTITY
}

Mutation + Query Variable:

mutation CreateProfileMutation($i: CreateProfileInput!) {
      createProfile(input: $i) {
        document {
          id
          name
          description
        }
      }
    }

{
  "i": {
    "content": {
      "name": "John",
      "description": "test"
    }
  }
}

Server Response:

{
  "errors": [
    {
      "message": "HTTP request to 'http://0.0.0.0:7007/api/v0/streams' failed with status 'Internal Server Error': {\"error\":\"Validation Error: data must be object\"}",
      "locations": [
        {
          "line": 2,
          "column": 7
        }
      ],
      "path": [
        "createProfile"
      ]
    }
  ],
  "data": {
    "createProfile": null
  }
}

Any idea what could be the reason?
Thanks again for all the help I’ve received so far in this forum!!

Stacktrace:

Error: HTTP request to 'http://0.0.0.0:7007/api/v0/streams' failed with status 'Internal Server Error': {"error":"Validation Error: data must be object"}
at fetchJson (webpack-internal:///./node_modules/@ceramicnetwork/common/lib/utils/http-utils.js:27:15) 
at async Document.createFromGenesis (webpack-internal:///./node_modules/@ceramicnetwork/http-client/lib/document.js:50:27)
at async CeramicClient.createStreamFromGenesis (webpack-internal:///./node_modules/@ceramicnetwork/http-client/lib/ceramic-http-client.js:61:24) at async DocumentLoader.single (webpack-internal:///./node_modules/@composedb/client/dist/loader.js:91:24) 
at async Context.createSingle (webpack-internal:///./node_modules/@composedb/client/dist/context.js:99:21) 
at async mutateAndGetPayload (webpack-internal:///./node_modules/@composedb/client/dist/schema.js:451:148) 
at async ComposeClient.execute (webpack-internal:///./node_modules/@composedb/client/dist/client.js:98:13) 
at async ComposeClient.executeQuery (webpack-internal:///./node_modules/@composedb/client/dist/client.js:118:16) 
{message: "HTTP request to 'http://0.0.0.0:7007/api/v0/stream…{"error":"Validation Error: data must be object"}", path: Array(1), locations: Array(1), extensions: Object, stack: "Error: HTTP request to 'http://0.0.0.0:7007/api/v0…_modules/@composedb/client/dist/client.js:118:16)", ...}

I set the log level to ‘0’ and picked up a bit more information in the server log:

[2022-09-29T23:19:40.736Z] ERROR: Error: Validation Error: data must be object
    at SchemaValidation.validateSchema (file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/@ceramicnetwork/stream-model-instance-handler/lib/schema-utils.js:19:19)
    at ModelInstanceDocumentHandler._validateContent (file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/@ceramicnetwork/stream-model-instance-handler/lib/model-instance-document-handler.js:112:41)
    at ModelInstanceDocumentHandler._applyGenesis (file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/@ceramicnetwork/stream-model-instance-handler/lib/model-instance-document-handler.js:57:20)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Repository.fromNetwork (file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/@ceramicnetwork/core/lib/state-management/repository.js:79:23)
    at async Repository._loadGenesis (file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/@ceramicnetwork/core/lib/state-management/repository.js:94:18)
    at async file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/@ceramicnetwork/core/lib/state-management/repository.js:102:59
    at async run (file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/p-queue/dist/index.js:115:36)

Is there a way to make the server log the actual HTTP req/res to help in debugging this.
I’m running Ceramic node 2.7.0 and ComposeDB 0.2.4

Thanks!

Hi, looks like you’re using enums in your schema, which are not officially supported yet. Could you please try a similar mutation with a schema not using enums to make sure this is not the source of the issue?

If the problem is still there, could you try using the --debug flag when running the Ceramic daemon to log the HTTP requests and get a better idea of the payload please?

1 Like

Thanks, Paul!
I used the “next-notes” examples from the ceramic github which used an ENUM type, so I assumed this is supported.
Removing the enum did not get rid of the problem unfortunately. I then switched the node to “debug” and it captured the following info below. Not sure if I’m interpreting this right, but the POST request does not have “params” which might explain the error. Thoughts?

[Fri, 30 Sep 2022 18:28:18 GMT] service=pubsub peer=12D3KooWA6aeZ2myxXjztpuFqP3hCMTwXQy9a7tTeQbwsNLWjjHL event=received topic=/ceramic/testnet-clay message.from=QmWiY3CbNawZjWnHXx3p3DXsg21pZYTj4CRY1iwMkhP8r3 message.seqno=17187710036362af message.topicIDs.0=/ceramic/testnet-clay message.typ=0 message.doc=k2t6wyfsu4pg0b2tvfcaagh7ri52zxqhpkzasry0vv0tn2xhd60jehjyrhuo7w message.stream=k2t6wyfsu4pg0b2tvfcaagh7ri52zxqhpkzasry0vv0tn2xhd60jehjyrhuo7w message.tip=bafyreiczc3evzq3hqyxhbxkbgt33zk3htxcfdtcfpdgpg3pl4lmgtsyx34
[2022-09-30T18:28:18.283Z] ERROR: Error: Validation Error: data must be object
    at SchemaValidation.validateSchema (file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/@ceramicnetwork/stream-model-instance-handler/lib/schema-utils.js:19:19)
    at ModelInstanceDocumentHandler._validateContent (file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/@ceramicnetwork/stream-model-instance-handler/lib/model-instance-document-handler.js:112:41)
    at ModelInstanceDocumentHandler._applyGenesis (file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/@ceramicnetwork/stream-model-instance-handler/lib/model-instance-document-handler.js:57:20)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Repository.fromNetwork (file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/@ceramicnetwork/core/lib/state-management/repository.js:79:23)
    at async Repository._loadGenesis (file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/@ceramicnetwork/core/lib/state-management/repository.js:94:18)
    at async file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/@ceramicnetwork/core/lib/state-management/repository.js:102:59
    at async run (file:///Users/jan/.npm/_npx/6ce17f4773701c2a/node_modules/p-queue/dist/index.js:115:36)
[Fri, 30 Sep 2022 18:28:18 GMT] service=http-access ip=127.0.0.1 ts=2022-09-30T18:28:18.289Z method=POST original_url=/api/v0/streams base_url=- path=/api/v0/streams params=- http_version=1.1 req_header- status=500 content_length=49 content_type="application/json; charset=utf-8" ref=- user_agent="node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" elapsed_ms=869.478 error_message="Validation Error: data must be object" error_code=-

Hey sorry no idea what is going on here and how to see what payload is received by the server, maybe @spencer or @ukstv would have some ideas?