Slice bounds out of range [1:0] when passing in a single digit BigInt value to operation, null when multiple digits.
Given this simple query for my issues:
query GetIssue($id: BigInt!) {
form: db_findUniqueIssue(where: { id: $id }) {
id
}
}
Passing in { "id": 1 } to the api throws -> "runtime error: slice bounds out of range [1:0]"
As you can clearly see, I am sure I have issues but Wundergraph just doesn't get them.
This only happens with a single digit like 1, however it returns a null value when a multiple digit value is given like 10, even if a record with that ID exists in the database.
The first error can be resolved with this fix: https://github.com/wundergraph/graphql-go-tools/pull/697. However it doesn't seem to be the root cause, the graph-go-tools repo is a bit dense for me to parse through but I think the BigInt value is getting incorrectly resolved to a string in the request.
I can work around this by replacing the BigInt with db_IssueWhereUniqueInput,
query GetIssue($where: db_IssueWhereUniqueInput!) {
form: db_findUniqueIssue(where: $where) {
id
}
}
And thankfully when I do this I can see that my issues are right where I left them.
Pasting the full stack trace below:
19:00:18.548 ERROR @wundergraph/server socket hang up error={"type":"Error","message":"socket hang up","stack":"Error: socket hang up\n at connResetException (node:internal/errors:705:14)\n at Socket.socketOnEnd (node:_http_client:518:23)\n at Socket.emit (node:events:525:35)\n at endReadableNT (node:internal/streams/readable:1358:12)\n at processTicksAndRejections (node:internal/process/task_queues:83:21)","code":"ECONNRESET"}
2023/12/12 19:00:23 http: panic serving 127.0.0.1:50782: runtime error: slice bounds out of range [1:0]
goroutine 75604 [running]:
net/http.(*conn).serve.func1()
/Users/runner/hostedtoolcache/go/1.20.8/x64/src/net/http/server.go:1854 +0xb0
panic({0x10395a080, 0x1401aa76510})
/Users/runner/hostedtoolcache/go/1.20.8/x64/src/runtime/panic.go:890 +0x258
github.com/wundergraph/graphql-go-tools/pkg/engine/resolve.extractStringWithQuotes({0x1, {0x0, 0x0, 0x0}, 0x0}, {0x1401cdc7006?, 0x1401d4ae6d8?, 0x102a942ac?})
/Users/runner/go/pkg/mod/github.com/wundergraph/[email protected]/pkg/engine/resolve/variable.go:637 +0x130
github.com/wundergraph/graphql-go-tools/pkg/engine/resolve.(*GraphQLVariableRenderer).RenderVariable(0x14024ed6b40, {0x103a69e88?, 0x1402731c4e0?}, {0x1401cdc7006?, 0x646461227b3a2274?, 0x506c616e6f697469?}, {0x103a5cc60, 0x14016d485e8})
/Users/runner/go/pkg/mod/github.com/wundergraph/[email protected]/pkg/engine/resolve/variable.go:369 +0xe8
github.com/wundergraph/graphql-go-tools/pkg/engine/resolve.(*InputTemplate).renderContextVariable(0x73666564242f2322?, 0x1401d00e360, {0x2, {0x0, 0x0, 0x0}, 0x1, {0x14005980070, 0x1, 0x1}, ...}, ...)
/Users/runner/go/pkg/mod/github.com/wundergraph/[email protected]/pkg/engine/resolve/inputtemplate.go:122 +0x330
github.com/wundergraph/graphql-go-tools/pkg/engine/resolve.(*InputTemplate).Render(0x140206b9248, 0x1401d00e360, {0x0, 0x0, 0x0}, 0x14016d485e8)
/Users/runner/go/pkg/mod/github.com/wundergraph/[email protected]/pkg/engine/resolve/inputtemplate.go:54 +0x204
github.com/wundergraph/graphql-go-tools/pkg/engine/resolve.(*Resolver).prepareSingleFetch(0x14012cdef00, 0x0?, 0x140206b9200, {0x0?, 0x6e55657265685768?, 0x6874695765757169?}, 0x1401348c330, 0x75706e49726f7461?)
/Users/runner/go/pkg/mod/github.com/wundergraph/[email protected]/pkg/engine/resolve/resolve.go:1397 +0x48
github.com/wundergraph/graphql-go-tools/pkg/engine/resolve.(*Resolver).resolveFetch(0x14012cdef00, 0x1401d00e360, {0x103a5cc20?, 0x140206b9200?}, {0x0, 0x0, 0x0}, 0x1401348c330)
/Users/runner/go/pkg/mod/github.com/wundergraph/[email protected]/pkg/engine/resolve/resolve.go:1328 +0x11c
github.com/wundergraph/graphql-go-tools/pkg/engine/resolve.(*Resolver).resolveObject(0x14012cdef00, 0x1401d00e360, 0x14024ed6a00, {0x0?, 0x1401d4aef88?, 0x102a8f55c?}, 0x14005b68af0)
/Users/runner/go/pkg/mod/github.com/wundergraph/[email protected]/pkg/engine/resolve/resolve.go:1156 +0x328
github.com/wundergraph/graphql-go-tools/pkg/engine/resolve.(*Resolver).resolveNode(0x1402a033e10?, 0x0?, {0x103a5cb60?, 0x14024ed6a00?}, {0x0?, 0x102395600?, 0x1401d4af058?}, 0x10222dc70?)
/Users/runner/go/pkg/mod/github.com/wundergraph/[email protected]/pkg/engine/resolve/resolve.go:414 +0x54
github.com/wundergraph/graphql-go-tools/pkg/engine/resolve.(*Resolver).ResolveGraphQLResponse(0x14012cdef00, 0x1401d00e360, 0x14007b1b770, {0x0, 0x0, 0x0}, {0x103a59e80, 0x140042a1b60})
/Users/runner/go/pkg/mod/github.com/wundergraph/[email protected]/pkg/engine/resolve/resolve.go:515 +0x17c
github.com/wundergraph/wundergraph/pkg/hooks.(*SynchronousOperationPipeline).Run(0x140058ab8c0, 0x1401d00e360, {0x103a67cb0, 0x1401c997800}, 0x2000?, 0x140042a1b60)
/Users/runner/work/wundergraph/wundergraph/pkg/hooks/pipeline.go:326 +0x1a8
github.com/wundergraph/wundergraph/pkg/apihandler.(*InternalApiHandler).ServeHTTP(0x1401316c960, {0x103a67cb0, 0x1401c997800}, 0x14002ae8600)
/Users/runner/work/wundergraph/wundergraph/pkg/apihandler/internalapihandler.go:403 +0x880
github.com/wundergraph/wundergraph/pkg/apihandler.(*operationMetricsHandler).Handler.func1({0x103a68490?, 0x14003dc4380}, 0x14002ae8600)
/Users/runner/work/wundergraph/wundergraph/pkg/apihandler/metrics.go:125 +0xb8
net/http.HandlerFunc.ServeHTTP(0x103a69e88?, {0x103a68490?, 0x14003dc4380?}, 0x34f210d0?)
/Users/runner/hostedtoolcache/go/1.20.8/x64/src/net/http/server.go:2122 +0x38
github.com/wundergraph/wundergraph/pkg/authentication.NewCSRFMw.func1.1({0x103a68490, 0x14003dc4380}, 0x14002ae8600)
/Users/runner/work/wundergraph/wundergraph/pkg/authentication/authentication.go:948 +0x37c
net/http.HandlerFunc.ServeHTTP(0x140119d1800?, {0x103a68490?, 0x14003dc4380?}, 0x14003dc4380?)
/Users/runner/hostedtoolcache/go/1.20.8/x64/src/net/http/server.go:2122 +0x38
github.com/wundergraph/wundergraph/pkg/authentication.NewLoadUserMw.func1.1({0x103a68490, 0x14003dc4380}, 0x14002ae8600)
/Users/runner/work/wundergraph/wundergraph/pkg/authentication/authentication.go:769 +0x178
net/http.HandlerFunc.ServeHTTP(0x14002ae8200?, {0x103a68490?, 0x14003dc4380?}, 0x1024f0900?)
/Users/runner/hostedtoolcache/go/1.20.8/x64/src/net/http/server.go:2122 +0x38
github.com/gorilla/mux.(*Router).ServeHTTP(0x14029be7440, {0x103a68490, 0x14003dc4380}, 0x14002aa5d00)
/Users/runner/go/pkg/mod/github.com/gorilla/[email protected]/mux.go:210 +0x19c
net/http.serverHandler.ServeHTTP({0x103a64e48?}, {0x103a68490, 0x14003dc4380}, 0x14002aa5d00)
/Users/runner/hostedtoolcache/go/1.20.8/x64/src/net/http/server.go:2936 +0x2d8
net/http.(*conn).serve(0x1402a7393b0, {0x103a69e88, 0x1402731c1b0})
/Users/runner/hostedtoolcache/go/1.20.8/x64/src/net/http/server.go:1995 +0x560
created by net/http.(*Server).Serve
/Users/runner/hostedtoolcache/go/1.20.8/x64/src/net/http/server.go:3089 +0x520