Incorrect line in error response for Undefined Type when followed by '!' (non-nullable)

Report a Dgraph Bug

What version of Dgraph are you using?

v20.07.2

Have you tried reproducing the issue with the latest release?

Yes

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

Use whatever means (HTTP POST, GraphiQL, etc) to set a GraphQL schema through updateGQLSchema mutation with the following simple type - note that the error is an undefined type at input line 3:

type User {
  first: FooBar!
}

# Response - incorrect line input:4:
resolving updateGQLSchema failed because input:4: Undefined type FooBar.\n

Remove the non-nullable operator and the line is correct.

type User {
  first: FooBar
}

# Response - correct line input:3:
resolving updateGQLSchema failed because input:3: Undefined type FooBar.\n

Expected behaviour and actual result.

See above.

Hi @clintwood - I may be going mad, but it would appear both snippets have the same result - an undefined type, and one reports the error at line 3 and the other reports the error at line 4. Copy-paste error?

Yes there was a copy paste error on the type in error - I have corrected that now - sorry about that!

However, the error I’m pointing to is subtle in that when the type in error FooBar is followed by the non-nullable operator ! then the error line number is out by one line.

Looks like a bug which is probably coming from the underlying library that we use. I have marked this as accepted and we’ll get to it next month.