romshark / dgraph_graphql_go

A GraphQL + Dgraph + Go + HTTP based backend service demo.
MIT License
50 stars 15 forks source link

Index out of range on query post with reactions #17

Closed DanielSharkov closed 5 years ago

DanielSharkov commented 5 years ago

When querying posts with reactions the API panics because of an index out of range

Full error log

2019/05/20 21:37:35 graphql: panic occurred: runtime error: index out of range
goroutine 16718 [running]:
github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/log.(*DefaultLogger).LogPanic(0x1a66438, 0x1673920, 0xc000444330, 0x1517ec0, 0x1a380f0)
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/log/log.go:21 +0x6d
github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec.execFieldSelection.func2.1(0xc00063e2a0, 0x1673920, 0xc000444330, 0xc0004bbef8, 0xc00000e500)
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec/exec.go:179 +0x8d
panic(0x1517ec0, 0x1a380f0)
    /usr/local/go/src/runtime/panic.go:522 +0x1b5
github.com/romshark/dgraph_graphql_go/api/graph/resolver.(*Reaction).Author(0xc000268100, 0x1673920, 0xc000458840, 0x0, 0x0, 0x0)
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/api/graph/resolver/reaction.go:138 +0x3c3
reflect.Value.call(0x1563440, 0xc0000b4128, 0x293, 0x15b2c4b, 0x4, 0xc00000e560, 0x1, 0x1, 0x1563440, 0x7, ...)
    /usr/local/go/src/reflect/value.go:447 +0x461
reflect.Value.Call(0x1563440, 0xc0000b4128, 0x293, 0xc00000e560, 0x1, 0x1, 0x293, 0x1, 0x0)
    /usr/local/go/src/reflect/value.go:308 +0xa4
github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec.execFieldSelection.func2(0xc00063e2a0, 0x1673920, 0xc000444330, 0xc00000e500, 0xc000450540, 0xc0004bbf40, 0x1673920, 0xc000458840, 0x0)
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec/exec.go:203 +0x450
github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec.execFieldSelection(0x1673920, 0xc000444330, 0xc00063e2a0, 0xc000450540, 0xc00000e500, 0x4ea4101)
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec/exec.go:223 +0x1aa
github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec.(*Request).execSelections.func1(0xc000584370, 0xc00063e2a0, 0x1673920, 0xc000444330, 0xc0003fe680, 0xc000450540)
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec/exec.go:83 +0x161
created by github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec.(*Request).execSelections
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec/exec.go:79 +0x5bc
2019/05/20 21:37:35 graphql: panic occurred: runtime error: index out of range
goroutine 16721 [running]:
github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/log.(*DefaultLogger).LogPanic(0x1a66438, 0x1673920, 0xc000444330, 0x1517ec0, 0x1a380f0)
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/log/log.go:21 +0x6d
github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec.execFieldSelection.func2.1(0xc00063e2a0, 0x1673920, 0xc000444330, 0xc0003d1ef8, 0xc0003fe6e0)
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec/exec.go:179 +0x8d
panic(0x1517ec0, 0x1a380f0)
    /usr/local/go/src/runtime/panic.go:522 +0x1b5
github.com/romshark/dgraph_graphql_go/api/graph/resolver.(*Reaction).Reactions(0xc000268100, 0x1673920, 0xc0006728a0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/api/graph/resolver/reaction.go:189 +0x5dc
reflect.Value.call(0x1563440, 0xc0000b4128, 0x1693, 0x15b2c4b, 0x4, 0xc0003fe740, 0x1, 0x1, 0x1563440, 0x7, ...)
    /usr/local/go/src/reflect/value.go:447 +0x461
reflect.Value.Call(0x1563440, 0xc0000b4128, 0x1693, 0xc0003fe740, 0x1, 0x1, 0x1693, 0x1, 0x0)
    /usr/local/go/src/reflect/value.go:308 +0xa4
github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec.execFieldSelection.func2(0xc00063e2a0, 0x1673920, 0xc000444330, 0xc0003fe6e0, 0xc000450680, 0xc0003d1f40, 0x1673920, 0xc0006728a0, 0x0)
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec/exec.go:203 +0x450
github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec.execFieldSelection(0x1673920, 0xc000444330, 0xc00063e2a0, 0xc000450680, 0xc0003fe6e0, 0x1)
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec/exec.go:223 +0x1aa
github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec.(*Request).execSelections.func1(0xc000584370, 0xc00063e2a0, 0x1673920, 0xc000444330, 0xc0003fe680, 0xc000450680)
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec/exec.go:83 +0x161
created by github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec.(*Request).execSelections
    /Volumes/ramdisk/go/src/github.com/romshark/dgraph_graphql_go/vendor/github.com/graph-gophers/graphql-go/internal/exec/exec.go:79 +0x5bc
2019/05/20 21:37:35 ERR: graph error: graphql: graphql: panic occurred: runtime error: index out of range; graphql: graphql: panic occurred: runtime error: index out of range;
romshark commented 5 years ago

Could you please also provide the query?

DanielSharkov commented 5 years ago

The query you asked for

query {
    posts {
        id
        author {
            id
            displayName
        }
        creation
        title
        contents
        reactions {
            id
            subject {
                ... on Reaction {
                    id
                    author {
                        id
                        displayName
                    }
                    emotion
                    message
                }
                ... on Post {
                    id
                    author {
                        id
                        displayName
                    }
                    title
                    contents
                }
            }
            author {
                id
                displayName
            }
            emotion
            message
            reactions {
                ...
            }
        }
    }
}
romshark commented 5 years ago

Fixed in 497e811