Simple mutation - A panic is trapped

Report a Dgraph Bug

What version of Dgraph are you using?

20.11.3

Have you tried reproducing the issue with the latest release?

NO

What is the hardware spec (RAM, OS)?

Ubuntu, Microk8s, 16GB RAM

Steps

Simple mutation as below

Stack Trace

E0423 17:30:12.196838      16 panics.go:34] panic: runtime error: invalid memory address or nil pointer dereference.
 query: mutation {
    addUser(input: {user: { username: "challap"}} ) { 
        user {
            username
        }
    }
}


 trace: goroutine 637 [running]:
runtime/debug.Stack(0xc007b22928, 0x1bc90c0, 0x2997600)
	/usr/local/go/src/runtime/debug/stack.go:24 +0x9f
github.com/dgraph-io/dgraph/graphql/api.PanicHandler(0xc007b23778, 0xc006e84c00, 0x3df)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/api/panics.go:34 +0x73
panic(0x1bc90c0, 0x2997600)
	/usr/local/go/src/runtime/panic.go:969 +0x1b9
github.com/dgraph-io/dgraph/graphql/schema.(*fieldDefinition).Type(0xc00775b380, 0xc006e84c20, 0x4)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/schema/wrappers.go:1832 +0x3e
github.com/dgraph-io/dgraph/graphql/resolve.existenceQueries(0x1f986a0, 0xc00775a7b0, 0x1fb0ba0, 0xc007275e20, 0x0, 0x0, 0xc0006d0c10, 0xc00775b2f0, 0xc0078218e0, 0x7ff91e4af748, ...)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/mutation_rewriter.go:1589 +0xc8f
github.com/dgraph-io/dgraph/graphql/resolve.(*AddRewriter).RewriteQueries(0xc00775b080, 0x1f986a0, 0xc00775a7b0, 0x1fb3740, 0xc00775b050, 0xc007b23098, 0xb20e9a, 0xc006d13970, 0x1d795ad, 0x3)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/mutation_rewriter.go:262 +0x525
github.com/dgraph-io/dgraph/graphql/resolve.(*dgraphResolver).rewriteAndExecute(0xc00775b0b0, 0x1f986a0, 0xc00775a7b0, 0x1fb3740, 0xc00775b050, 0x0, 0xc007b23500)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/mutation.go:267 +0x322
github.com/dgraph-io/dgraph/graphql/resolve.(*dgraphResolver).Resolve(0xc00775b0b0, 0x1f986a0, 0xc00775a7b0, 0x1fb3740, 0xc00775b050, 0x0, 0x1f98600)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/mutation.go:198 +0x35f
github.com/dgraph-io/dgraph/graphql/resolve.(*RequestResolver).Resolve(0xc000675a80, 0x1f986a0, 0xc00775a7b0, 0xc006abf680, 0xc007708370)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/resolver.go:538 +0x651
github.com/dgraph-io/dgraph/graphql/web.(*graphqlHandler).ServeHTTP(0xc000110260, 0x1f91ea0, 0xc00647a0e0, 0xc006406e00)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/web/http.go:228 +0x3b3
github.com/dgraph-io/graphql-transport-ws/graphqlws.NewHandlerFunc.func1(0x1f91ea0, 0xc00647a0e0, 0xc006406e00)
	/go/pkg/mod/github.com/dgraph-io/graphql-transport-ws@v0.0.0-20200916064635-48589439591b/graphqlws/http.go:39 +0xd5
net/http.HandlerFunc.ServeHTTP(0xc0000c5110, 0x1f91ea0, 0xc00647a0e0, 0xc006406e00)
	/usr/local/go/src/net/http/server.go:2042 +0x44
github.com/dgraph-io/dgraph/graphql/web.commonHeaders.func1(0x1f91ea0, 0xc00647a0e0, 0xc006406e00)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/web/http.go:332 +0x266
net/http.HandlerFunc.ServeHTTP(0xc000110280, 0x1f91ea0, 0xc00647a0e0, 0xc006406e00)
	/usr/local/go/src/net/http/server.go:2042 +0x44
github.com/dgraph-io/dgraph/graphql/web.recoveryHandler.func1(0x1f91ea0, 0xc00647a0e0, 0xc006406e00)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/web/http.go:345 +0xb1
net/http.HandlerFunc.ServeHTTP(0xc0001102a0, 0x1f91ea0, 0xc00647a0e0, 0xc006406e00)
	/usr/local/go/src/net/http/server.go:2042 +0x44
net/http.(*ServeMux).ServeHTTP(0x2bbbe40, 0x1f91ea0, 0xc00647a0e0, 0xc006406e00)
	/usr/local/go/src/net/http/server.go:2417 +0x1ad
net/http.serverHandler.ServeHTTP(0xc0004f00e0, 0x1f91ea0, 0xc00647a0e0, 0xc006406e00)
	/usr/local/go/src/net/http/server.go:2843 +0xa3
net/http.(*conn).serve(0xc00617b7c0, 0x1f985e0, 0xc006abf540)
	/usr/local/go/src/net/http/server.go:1925 +0x8ad
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2969 +0x36c

Stack trace with latest version: 21.03.0

 trace: goroutine 357 [running]:
runtime/debug.Stack(0xc00752e760, 0x1e71100, 0x2e42720)
	/usr/local/go/src/runtime/debug/stack.go:24 +0x9f
github.com/dgraph-io/dgraph/graphql/api.PanicHandler(0xc00752f518, 0xc006bed400, 0x3df)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/api/panics.go:34 +0x76
panic(0x1e71100, 0x2e42720)
	/usr/local/go/src/runtime/panic.go:965 +0x1b9
github.com/dgraph-io/dgraph/graphql/schema.(*fieldDefinition).Type(0xc007297650, 0xc006bed420, 0x4)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/schema/wrappers.go:2340 +0x3e
github.com/dgraph-io/dgraph/graphql/resolve.existenceQueries(0x22e8e10, 0xc007296ab0, 0x2306378, 0xc006670690, 0x0, 0x0, 0xc007209f70, 0xc0072975c0, 0xc006b41368, 0x203001, ...)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/mutation_rewriter.go:1788 +0xda3
github.com/dgraph-io/dgraph/graphql/resolve.(*AddRewriter).RewriteQueries(0xc007297380, 0x22e8e10, 0xc007296ab0, 0x230bcd8, 0xc007297350, 0x1, 0xa812ac, 0x10, 0xc00752f000, 0xb458d6)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/mutation_rewriter.go:280 +0x525
github.com/dgraph-io/dgraph/graphql/resolve.(*dgraphResolver).rewriteAndExecute(0xc006b348a0, 0x22e8e10, 0xc007296ab0, 0x230bcd8, 0xc007297350, 0x0, 0xc00752f300)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/mutation.go:269 +0x35c
github.com/dgraph-io/dgraph/graphql/resolve.(*dgraphResolver).Resolve(0xc006b348a0, 0x22e8e10, 0xc007296ab0, 0x230bcd8, 0xc007297350, 0x0, 0x0)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/mutation.go:197 +0x35f
github.com/dgraph-io/dgraph/graphql/resolve.(*RequestResolver).Resolve(0xc00667df60, 0x22e8e10, 0xc007296ab0, 0xc0070f1b80, 0xc0070ee7e0)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/resolver.go:601 +0x7d2
github.com/dgraph-io/dgraph/graphql/admin.(*graphqlHandler).ServeHTTP(0xc00003edc0, 0x22e21c8, 0xc000146c40, 0xc00676d400)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/admin/http.go:239 +0x4b0
github.com/dgraph-io/graphql-transport-ws/graphqlws.NewHandlerFunc.func1(0x22e21c8, 0xc000146c40, 0xc00676d400)
	/go/pkg/mod/github.com/dgraph-io/graphql-transport-ws@v0.0.0-20210223074046-e5b8b80bb4ed/graphqlws/http.go:40 +0xd5
net/http.HandlerFunc.ServeHTTP(0xc00023bc80, 0x22e21c8, 0xc000146c40, 0xc00676d400)
	/usr/local/go/src/net/http/server.go:2069 +0x44
github.com/dgraph-io/dgraph/graphql/admin.commonHeaders.func1(0x22e21c8, 0xc000146c40, 0xc00676d400)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/admin/http.go:336 +0x14b
net/http.HandlerFunc.ServeHTTP(0xc000010210, 0x22e21c8, 0xc000146c40, 0xc00676d400)
	/usr/local/go/src/net/http/server.go:2069 +0x44
github.com/dgraph-io/dgraph/graphql/admin.recoveryHandler.func1(0x22e21c8, 0xc000146c40, 0xc00676d400)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/admin/http.go:349 +0xb1
net/http.HandlerFunc.ServeHTTP(0xc000010228, 0x22e21c8, 0xc000146c40, 0xc00676d400)
	/usr/local/go/src/net/http/server.go:2069 +0x44
github.com/dgraph-io/dgraph/dgraph/cmd/alpha.setupServer.func1(0x22e21c8, 0xc000146c40, 0xc00676d400)
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/alpha/run.go:549 +0x1b8
net/http.HandlerFunc.ServeHTTP(0xc000010f00, 0x22e21c8, 0xc000146c40, 0xc00676d400)
	/usr/local/go/src/net/http/server.go:2069 +0x44
net/http.(*ServeMux).ServeHTTP(0xc0006d2140, 0x22e21c8, 0xc000146c40, 0xc00676d400)
	/usr/local/go/src/net/http/server.go:2448 +0x1ad
github.com/dgraph-io/dgraph/ee/audit.AuditRequestHttp.func1(0x22e21c8, 0xc000146c40, 0xc00676d400)
	/ext-go/1/src/github.com/dgraph-io/dgraph/ee/audit/interceptor_ee.go:91 +0x75
net/http.HandlerFunc.ServeHTTP(0xc000010078, 0x22e21c8, 0xc000146c40, 0xc00676d400)
	/usr/local/go/src/net/http/server.go:2069 +0x44
net/http.(*ServeMux).ServeHTTP(0x30716a0, 0x22e21c8, 0xc000146c40, 0xc00676d400)
	/usr/local/go/src/net/http/server.go:2448 +0x1ad
net/http.serverHandler.ServeHTTP(0xc0001462a0, 0x22e21c8, 0xc000146c40, 0xc00676d400)
	/usr/local/go/src/net/http/server.go:2887 +0xa3
net/http.(*conn).serve(0xc0065b2fa0, 0x22e8e10, 0xc0070f1a80)
	/usr/local/go/src/net/http/server.go:1952 +0x8cd
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:3013 +0x39b
I0423 17:40:19.662863      16 draft.go:180] Operation started with id: opRollup

yeah, I am able t reproduce the issue in the master branch and fix it soon.

Hey @challapradyumna, Can you mention the definition of the type User. I guess it looks something like this:-

type User {
  username: String
  ...
}

Then your mutation is ill-formed which is resulting in panic. The correct mutation should be:-

mutation {
    addUser(input: [{ username: "challap"}] ) { 
        user {
            username
        }
    }
}
2 Likes

You are right.

type User @secret(field: "password")
{
  id: ID!
  username: String! @id
}

The error reporting might be improved …

1 Like

Yeah, we will soon fix it. This should not result in a panic.

1 Like