Dgraph: Parsing error is incorrect

Created on 11 Sep 2019  路  6Comments  路  Source: dgraph-io/dgraph

What version of Dgraph are you using?

Dgraph 1.1.0

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, OS)?

Running on docker for Mac

Steps to reproduce the issue (command/config used to run Dgraph).

Send this mutation:

{
  "set": [
    {
      "uid": "0x1",
      "friends_with": [
        {
          "uid": "0x3",
          "friends_with|good": false,
        }
      ]
    }
  ]
}

There's a mistake since there's an extra , after false.

Expected behaviour and actual result.

I expect to see a parsing error on line 8, where the extra comma is found. Maybe on line 9?

Instead, I get this error:

Error Name: t

Message: while lexing {
  "set": [
    {
      "uid": "0x1",
      "friends_with": [
        {
          "uid": "0x3",
          "friends_with|good": false,
        }
      ]
    }
  ]
} at line 2 column 2: Unrecognized character inside mutation: U+0022 '"'

URL: http://localhost:8080/mutate?commitNow=true
areusability kinbug prioritP2 statuaccepted

All 6 comments

So it looks like when the mutate endpoint will try to parse the input as JSON. If that fails, it will try to do the mutation in the rdf format. So that's what the error message means. I am not sure how to fix it when Dgraph is making a guess about the format. If the mutation is invalid, how could it tell it's an invalid JSON or and invalid RDF?

Maybe it's enough to include the format it's using for parsing in the error message

Maybe we can determine the format based on left curly bracket in the front. And then return parsing error accordingly.

Is this then a Ratel bug since it tries to figure out the mutation format?

When sent via curl with the right Content-Type header, I get this error:

{"errors":[{"message":"invalid character '}' looking for beginning of object key string","extensions":{"code":"ErrorInvalidRequest"}}]}

I guess it's better, but still not really helpful.

It would depend on what we are using to parse the JSON. I don't think we are using the same parser as the RDF so we cannot add line numbers. But I'll look into it to see if we can improve it somehow.

Any update on this issue, @martinmr ?

sorry, I haven't had a chance to look at it, yet. I'll get to it once I am done with the type system PRs I have open.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mbudge picture mbudge  路  3Comments

protheusfr picture protheusfr  路  4Comments

allen-munsch picture allen-munsch  路  4Comments

janardhan1993 picture janardhan1993  路  3Comments

ShawnMilo picture ShawnMilo  路  4Comments