Open netixx opened 1 year ago
Panic during extension evaluation while when the body fails to parse.
Normal error response
N/A
go run github.com/99designs/gqlgen version
go version
I get the following panic:
missing operation context goroutine 119 [running]: runtime/debug.Stack() /usr/local/go/src/runtime/debug/stack.go:24 +0x65 runtime/debug.PrintStack() /usr/local/go/src/runtime/debug/stack.go:16 +0x19 github.com/99designs/gqlgen/graphql.DefaultRecover({0x0?, 0x8?}, {0x1097a40?, 0x1414270?}) /go/pkg/mod/github.com/99designs/gqlgen@v0.17.36/graphql/recovery.go:17 +0x71 github.com/99designs/gqlgen/graphql/executor.(*Executor).PresentRecoveredError(0xc000260140, {0x142ef98, 0xc0005fea50}, {0x1097a40?, 0x1414270?}) /go/pkg/mod/github.com/99designs/gqlgen@v0.17.36/graphql/executor/executor.go:156 +0x46 github.com/99designs/gqlgen/graphql/handler.(*Server).ServeHTTP.func1() /go/pkg/mod/github.com/99designs/gqlgen@v0.17.36/graphql/handler/server.go:104 +0x99 panic({0x1097a40, 0x1414270}) /usr/local/go/src/runtime/panic.go:884 +0x212 github.com/99designs/gqlgen/graphql.GetOperationContext({0x142ef98?, 0xc0005feab0?}) /go/pkg/mod/github.com/99designs/gqlgen@v0.17.36/graphql/context_operation.go:65 +0x71 github.com/99designs/gqlgen-contrib/prometheus.Tracer.InterceptResponse({}, {0x142ef98, 0xc0005feab0}, 0xc0002af128) /go/pkg/mod/github.com/99designs/gqlgen-contrib@v0.1.1-0.20230605152740-d49a0a0239a7/prometheus/prometheus.go:129 +0x45 github.com/99designs/gqlgen/graphql/executor.processExtensions.func6({0x142ef98, 0xc0005feab0}, 0x12db030) /go/pkg/mod/github.com/99designs/gqlgen@v0.17.36/graphql/executor/extensions.go:91 +0xb0 github.com/99designs/gqlgen/graphql/executor.processExtensions.func6.1({0x142ef98?, 0xc0005feab0?}) /go/pkg/mod/github.com/99designs/gqlgen@v0.17.36/graphql/executor/extensions.go:92 +0x2b github.com/ravilushqa/otelgqlgen.Tracer.InterceptResponse({{0x0, 0x0}, {0x1422560, 0xc0000a99c0}, 0x12dbc30, 0x12dbc28}, {0x142ef98, 0xc0005feab0}, 0xc0002af110) /go/pkg/mod/github.com/ravilushqa/otelgqlgen@v0.13.1/gqlgen.go:63 +0x879 github.com/99designs/gqlgen/graphql/executor.processExtensions.func6({0x142ef98, 0xc0005feab0}, 0x12db030) /go/pkg/mod/github.com/99designs/gqlgen@v0.17.36/graphql/executor/extensions.go:91 +0xb0 github.com/99designs/gqlgen/graphql/executor.(*Executor).DispatchError(0xc000260140, {0x142ef98, 0xc0005fea50}, {0xc0000125a8, 0x1, 0xc0005fea80?}) /go/pkg/mod/github.com/99designs/gqlgen@v0.17.36/graphql/executor/executor.go:144 +0x11c github.com/99designs/gqlgen/graphql/handler/transport.POST.Do({0x142eef0?}, {0x7ff796a4ed40?, 0xc000107200}, 0xc000107900, {0x142b830, 0xc000260140}) /go/pkg/mod/github.com/99designs/gqlgen@v0.17.36/graphql/handler/transport/http_post.go:76 +0x6b0 github.com/99designs/gqlgen/graphql/handler.(*Server).ServeHTTP(0xc00007c6c0, {0x7ff796a4ed40, 0xc000107200}, 0xc000107900) /go/pkg/mod/github.com/99designs/gqlgen@v0.17.36/graphql/handler/server.go:121 +0x212 ... github.com/gin-gonic/gin.(*Context).Next(...) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc000007860, 0xc000107200) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 +0x671 github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc000007860, {0x142df00?, 0xc000158fc0}, 0xc000107800) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 +0x1dd net/http.serverHandler.ServeHTTP({0x1429db0?}, {0x142df00, 0xc000158fc0}, 0xc000107800) /usr/local/go/src/net/http/server.go:2947 +0x30c net/http.(*conn).serve(0xc000260f00, {0x142ef98, 0xc0001b3980}) /usr/local/go/src/net/http/server.go:1991 +0x607 created by net/http.(*Server).Serve /usr/local/go/src/net/http/server.go:3102 +0x4db
When the body fails to parse and i use the gqlgen-contrib/prmetheus extension:
import gqlprom "github.com/99designs/gqlgen-contrib/prometheus" graphqlHandler.Use(gqlprom.Tracer{})
I see that there is a WithOperationContext on line 84
WithOperationContext
resp := exec.DispatchError(graphql.WithOperationContext(ctx, rc), OpErr)
but not on line 76, so maybe all error cases are not covered (maybe related to https://github.com/99designs/gqlgen/issues/1067) ?
This can also happen when the payload is not valid JSON.
What happened?
Panic during extension evaluation while when the body fails to parse.
What did you expect?
Normal error response
Minimal graphql.schema and models to reproduce
N/A
versions
go run github.com/99designs/gqlgen version
: v0.17.34go version
: go version go1.20.7 linux/amd64I get the following panic:
When the body fails to parse and i use the gqlgen-contrib/prmetheus extension:
I see that there is a
WithOperationContext
on line 84but not on line 76, so maybe all error cases are not covered (maybe related to https://github.com/99designs/gqlgen/issues/1067) ?