A panic was trapped on a simple mutation

Hi

I have a Type Task which queries fine and returns the following

query MyQuery {
queryTask {
iD
title
Comments
}
}

{
“data”: {
“queryTask”: [
{
“iD”: “0x4e41”,
“title”: “Task 1”,
“Comments”:
}
]
},
“extensions”: {

}

When I try and do a basic mutation to change the title created with the api explorer tool

mutation MyMutation {
updateTask(input: {filter: {iD: “0x4e41”}, set: {title: “Bob”}}) {
numUids
}
}

I get the error

{
“errors”: [
{
“message”: “Internal Server Error - a panic was trapped. This indicates a bug in the GraphQL server. A stack trace was logged. Please let us know by filing an issue with the stack trace.”
}
]
}

I am new to this but thought I would get past the graph QL equivalent of ‘hello world!’ :wink:

Any ideas?

Hi @haPartnerships,

Welcome to Dgraph Community !!

I was able to reproduce this issue. The problem occurs because iD in filter expects a list of IDs while just the ID has been provided.

The update mutation should work with the following input to updateTask,

updateTask(input: {filter: {iD: [ “0x4e41” ] }, set: {title: “Bob”}})

Note the [ ] around "0x4e41" .

Thanks for the post. I do agree that the error thrown should have been more verbose and pointed towards the fact that there is something wrong with the input provided to update mutation rather than panicking. I am accepting this panicking as a bug and it will be fixed to a more verbose error.

Do let us know if you have any other questions.

Reference for Update Mutations: https://dgraph.io/docs/graphql/mutations/update/ .

For the sake of completeness, This PR has fixed this behaviour on master branch. Later slash graphql and dgraph releases will also have support for coercing a single object to list.

The update mutation won’t cause panic and will update the node gracefully on using master or later releases.

@rajas

Small note, API explorer still formats these filter*id fields without brackets.

This caught me too. I’m getting a panic as well and I’m using the API Explorer.

Looks like the panic is still happening FYI @rajas

This issue exists in v20.11 and prior releases. It has been fixed in master.

I have just verified the same and it is working fine on master as well as on Slash for me.
My Slash instance had v20.11.2-rc1-15-gc358c26e deployed.

Could you please check which Dgraph Version is running in your Slash backend by going to the Settings tab?

If it is prior to v20.11.2-rc1, then it makes sense that you encountered this issue, otherwise if you are still getting the same issue on v20.11.2-rc1, please share with us a set of reproducible steps and we will be happy to look into it.

Thanks! My backend is v20.11.0-11-gb36b4862

Is there a way to upgrade our backend?

1 Like