Errors are unhelpful

Moved from GitHub dgraph-js/61

Posted by felixfbecker:

I am running a mutation that fails with this error:

Error: 2 UNKNOWN: Input for predicate contents of type scalar is uid
    at Object.exports.createStatusError (/Users/felix/git/sourcegraph/lsif/server/node_modules/grpc/src/common.js:91:15)
    at Object.onReceiveStatus (/Users/felix/git/sourcegraph/lsif/server/node_modules/grpc/src/client_interceptors.js:1204:28)
    at InterceptingListener._callNext (/Users/felix/git/sourcegraph/lsif/server/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/Users/felix/git/sourcegraph/lsif/server/node_modules/grpc/src/client_interceptors.js:618:8)
    at callback (/Users/felix/git/sourcegraph/lsif/server/node_modules/grpc/src/client_interceptors.js:845:24) {
  code: 2,
  metadata: Metadata { _internal_repr: {}, flags: 0 },
  details: 'Input for predicate contents of type scalar is uid'

The mutation contains thousands of nquads, so I have no idea which one is wrong. I would expect the error to include some properties about which nquad failed to get added, at least the name of the predicate. The error code also always seems to be 2, and the stack trace doesn’t include the user code.

As a comparison, errors from the node Postgres client pg have properties that specify the query, position, even the name of a column contraint that failed.

campoy commented :

Thanks for the report, @felixfbecker

I do wonder whether this is an issue with the error message itself (so dgraph-io/dgraph) or the way it ends up being displayed (this repo).

@paulftw, could you check whether we could improve the error message on this repository by at least showing which of all of the mutations was actually wrong?

felixfbecker commented :

Actually I noticed that the name of the predicate here was “contents”, it was just not clear because it wasn’t quoted and made sense as a sentence. But I think overall that would not help a lot - I’d still need a proper stack trace, maybe the index of the nquad in the list, the actual UID values of subject and object - anything that helps to find the bug

campoy commented :

Yeah, I think the message can be improved, yeah.
I’m sure @paulftw will have a look at the issue (later on, as he’s in a different timezone).