cayleygraph / cayley

An open-source graph database
https://cayley.io
Apache License 2.0
14.83k stars 1.25k forks source link

Homebrew: panics when accessing http interface in the browser #932

Closed milosgajdos closed 4 years ago

milosgajdos commented 4 years ago

Description

Program panics when running the http subcommand:

Steps to reproduce the issue:

  1. install latest tagged release (Cayley version: 0.7.7 Git commit hash: dcf764f)
  2. Start the http interface: cayley http
  3. Visit the printed URL in the browser: listening on 127.0.0.1:64210, web interface at http://127.0.0.1:64210

Received results:

The program panics

$ cayley http
ERROR: logging before flag.Parse: E0416 09:03:27.896449   13863 cayley.go:142] The assets flag is deprecated as assets are provided as part of the binary.
I0416 09:03:27.897303   13863 command.go:805] Cayley version: 0.7.7 (dcf764f)
I0416 09:03:27.898217   13863 http.go:20] using backend "memstore"
I0416 09:03:27.898733   13863 command.go:826] listening on 127.0.0.1:64210, web interface at http://127.0.0.1:64210
2020/04/16 09:03:31 http: panic serving 127.0.0.1:56195: runtime error: invalid memory address or nil pointer dereference
goroutine 12 [running]:
net/http.(*conn).serve.func1(0xc00027b0e0)
    /usr/local/Cellar/go/1.13.1/libexec/src/net/http/server.go:1767 +0x139
panic(0x508cce0, 0x6090b90)
    /usr/local/Cellar/go/1.13.1/libexec/src/runtime/panic.go:679 +0x1b2
html/template.(*Template).lookupAndEscapeTemplate(0x0, 0xc000154cc0, 0xa, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.13.1/libexec/src/html/template/template.go:144 +0x4e
html/template.(*Template).ExecuteTemplate(0x0, 0x54f7800, 0xc0002820e0, 0xc000154cc0, 0xa, 0x0, 0x0, 0x60af040, 0x2)
    /usr/local/Cellar/go/1.13.1/libexec/src/html/template/template.go:133 +0x43
github.com/cayleygraph/cayley/internal/http.serveUI(0x5519300, 0xc0002820e0, 0xc00011cd00, 0x0, 0x0, 0x0)
    /private/tmp/cayley-20191015-59110-t1xb58/src/github.com/cayleygraph/cayley/internal/http/ui.go:35 +0x156
github.com/julienschmidt/httprouter.(*Router).ServeHTTP(0xc0000ee600, 0x5519300, 0xc0002820e0, 0xc00011cd00)
    /private/tmp/cayley-20191015-59110-t1xb58/pkg/mod/github.com/julienschmidt/httprouter@v1.2.0/router.go:334 +0x95e
net/http.(*ServeMux).ServeHTTP(0x60af040, 0x5519300, 0xc0002820e0, 0xc00011cd00)
    /usr/local/Cellar/go/1.13.1/libexec/src/net/http/server.go:2387 +0x1bd
net/http.serverHandler.ServeHTTP(0xc00029a000, 0x5519300, 0xc0002820e0, 0xc00011cd00)
    /usr/local/Cellar/go/1.13.1/libexec/src/net/http/server.go:2802 +0xa4
net/http.(*conn).serve(0xc00027b0e0, 0x5520c00, 0xc0000ee740)
    /usr/local/Cellar/go/1.13.1/libexec/src/net/http/server.go:1890 +0x875
created by net/http.(*Server).Serve
    /usr/local/Cellar/go/1.13.1/libexec/src/net/http/server.go:2927 +0x38e
2020/04/16 09:03:31 http: panic serving 127.0.0.1:56197: runtime error: invalid memory address or nil pointer dereference
goroutine 63 [running]:
net/http.(*conn).serve.func1(0xc000274dc0)
    /usr/local/Cellar/go/1.13.1/libexec/src/net/http/server.go:1767 +0x139
panic(0x508cce0, 0x6090b90)
    /usr/local/Cellar/go/1.13.1/libexec/src/runtime/panic.go:679 +0x1b2
html/template.(*Template).lookupAndEscapeTemplate(0x0, 0xc000154da0, 0xa, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.13.1/libexec/src/html/template/template.go:144 +0x4e
html/template.(*Template).ExecuteTemplate(0x0, 0x54f7800, 0xc0002821c0, 0xc000154da0, 0xa, 0x0, 0x0, 0x60af040, 0x2)
    /usr/local/Cellar/go/1.13.1/libexec/src/html/template/template.go:133 +0x43
github.com/cayleygraph/cayley/internal/http.serveUI(0x5519300, 0xc0002821c0, 0xc00011ce00, 0x0, 0x0, 0x0)
    /private/tmp/cayley-20191015-59110-t1xb58/src/github.com/cayleygraph/cayley/internal/http/ui.go:35 +0x156
github.com/julienschmidt/httprouter.(*Router).ServeHTTP(0xc0000ee600, 0x5519300, 0xc0002821c0, 0xc00011ce00)
    /private/tmp/cayley-20191015-59110-t1xb58/pkg/mod/github.com/julienschmidt/httprouter@v1.2.0/router.go:334 +0x95e
net/http.(*ServeMux).ServeHTTP(0x60af040, 0x5519300, 0xc0002821c0, 0xc00011ce00)
    /usr/local/Cellar/go/1.13.1/libexec/src/net/http/server.go:2387 +0x1bd
net/http.serverHandler.ServeHTTP(0xc00029a000, 0x5519300, 0xc0002821c0, 0xc00011ce00)
    /usr/local/Cellar/go/1.13.1/libexec/src/net/http/server.go:2802 +0xa4
net/http.(*conn).serve(0xc000274dc0, 0x5520c00, 0xc0000ee8c0)
    /usr/local/Cellar/go/1.13.1/libexec/src/net/http/server.go:1890 +0x875
created by net/http.(*Server).Serve
    /usr/local/Cellar/go/1.13.1/libexec/src/net/http/server.go:2927 +0x38e

Expected results:

I expect to be able to visit HTTP interface in the browser

Output of cayley version or commit hash:

$ cayley version
ERROR: logging before flag.Parse: E0416 09:03:21.287714   13841 cayley.go:142] The assets flag is deprecated as assets are provided as part of the binary.
Cayley version: 0.7.7
Git commit hash: dcf764f

Environment details:

Backend database: memory OS: macOS Catalina 10.15.3 (19D76)

I had a look into the panicking code cayleygraph/cayley/internal/http/ui.go:35 and I suspect the query.html template is referencing some named templates which do not seem to exist so maybe that's causing the panic?

iddan commented 4 years ago

Hey, thank you for reporting. This is a known issue. This weekend I finally completed my pull request to Homebrew to fix the build: https://github.com/Homebrew/homebrew-core/pull/53729 In the midtime, you can run Cayley using docker or by installing the binary from the releases page.

iddan commented 4 years ago

The PR is merged. You can now reinstall Cayley from brew and the problem should be fixed