gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.95k stars 7.54k forks source link

Server panic when checking out a Git branch #10861

Open willfaught opened 1 year ago

willfaught commented 1 year ago
Change detected, rebuilding site.
2023-03-22 23:19:05.524 -0700
ERROR 2023/03/22 23:19:05 Failed to reload config: add site dependencies: load resources: loading templates: "/Users/Will/Developer/paige/layouts/partials/paige/subpages.html:130:1": parse failed unexpected EOF
Rebuilt in 33 ms
2023/03/22 23:23:21 http: panic serving 127.0.0.1:65080: runtime error: invalid memory address or nil pointer dereference
goroutine 23818 [running]:
net/http.(*conn).serve.func1()
    net/http/server.go:1854 +0xbf
panic({0x101b84aa0, 0x1034c0460})
    runtime/panic.go:890 +0x263
github.com/gohugoio/hugo/commands.(*commandeer).serve.func1(0xc005f52000?)
    github.com/gohugoio/hugo/commands/server.go:562 +0x32
github.com/gohugoio/hugo/commands.(*commandeer).serve.func2({0x101b711a0, 0xc003cd8180})
    github.com/gohugoio/hugo/commands/server.go:578 +0x4f
github.com/gohugoio/hugo/commands.(*fileServer).createEndpoint.func1.1({0x1024890e0, 0xc00152e1c0}, 0xc004950100)
    github.com/gohugoio/hugo/commands/server.go:380 +0x464
net/http.HandlerFunc.ServeHTTP(0xc00523c000?, {0x1024890e0?, 0xc00152e1c0?}, 0x1000125a8?)
    net/http/server.go:2122 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x1024890e0, 0xc00152e1c0}, 0xc004950100)
    net/http/server.go:2500 +0x149
net/http.serverHandler.ServeHTTP({0xc003cd8090?}, {0x1024890e0, 0xc00152e1c0}, 0xc004950100)
    net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc00303e000, {0x10248a5e0, 0xc002a390e0})
    net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
    net/http/server.go:3089 +0x5ed
2023/03/22 23:23:21 http: panic serving 127.0.0.1:65082: runtime error: invalid memory address or nil pointer dereference
goroutine 23842 [running]:
net/http.(*conn).serve.func1()
    net/http/server.go:1854 +0xbf
panic({0x101b84aa0, 0x1034c0460})
    runtime/panic.go:890 +0x263
github.com/gohugoio/hugo/commands.(*commandeer).serve.func1(0xc005f52000?)
    github.com/gohugoio/hugo/commands/server.go:562 +0x32
github.com/gohugoio/hugo/commands.(*commandeer).serve.func2({0x101b711a0, 0xc0047ca210})
    github.com/gohugoio/hugo/commands/server.go:578 +0x4f
github.com/gohugoio/hugo/commands.(*fileServer).createEndpoint.func1.1({0x1024890e0, 0xc003fa6000}, 0xc004154100)
    github.com/gohugoio/hugo/commands/server.go:380 +0x464
net/http.HandlerFunc.ServeHTTP(0xc00664e080?, {0x1024890e0?, 0xc003fa6000?}, 0x1000125a8?)
    net/http/server.go:2122 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x1024890e0, 0xc003fa6000}, 0xc004154100)
    net/http/server.go:2500 +0x149
net/http.serverHandler.ServeHTTP({0xc0047ca0f0?}, {0x1024890e0, 0xc003fa6000}, 0xc004154100)
    net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc004a34990, {0x10248a5e0, 0xc002a390e0})
    net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
    net/http/server.go:3089 +0x5ed
2023/03/22 23:23:21 http: panic serving 127.0.0.1:65084: runtime error: invalid memory address or nil pointer dereference
goroutine 23640 [running]:
net/http.(*conn).serve.func1()
    net/http/server.go:1854 +0xbf
panic({0x101b84aa0, 0x1034c0460})
    runtime/panic.go:890 +0x263
github.com/gohugoio/hugo/commands.(*commandeer).serve.func1(0xc005f52000?)
    github.com/gohugoio/hugo/commands/server.go:562 +0x32
github.com/gohugoio/hugo/commands.(*commandeer).serve.func2({0x101b711a0, 0xc005036180})
    github.com/gohugoio/hugo/commands/server.go:578 +0x4f
github.com/gohugoio/hugo/commands.(*fileServer).createEndpoint.func1.1({0x1024890e0, 0xc001bae000}, 0xc00305a000)
    github.com/gohugoio/hugo/commands/server.go:380 +0x464
net/http.HandlerFunc.ServeHTTP(0xc002644000?, {0x1024890e0?, 0xc001bae000?}, 0x1000125a8?)
    net/http/server.go:2122 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x1024890e0, 0xc001bae000}, 0xc00305a000)
    net/http/server.go:2500 +0x149
net/http.serverHandler.ServeHTTP({0xc005036090?}, {0x1024890e0, 0xc001bae000}, 0xc00305a000)
    net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc0005fc3f0, {0x10248a5e0, 0xc002a390e0})
    net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
    net/http/server.go:3089 +0x5ed
2023/03/22 23:24:57 http: panic serving 127.0.0.1:65095: runtime error: invalid memory address or nil pointer dereference
goroutine 23820 [running]:
net/http.(*conn).serve.func1()
    net/http/server.go:1854 +0xbf
panic({0x101b84aa0, 0x1034c0460})
    runtime/panic.go:890 +0x263
github.com/gohugoio/hugo/commands.(*commandeer).serve.func1(0xc005f52000?)
    github.com/gohugoio/hugo/commands/server.go:562 +0x32
github.com/gohugoio/hugo/commands.(*commandeer).serve.func2({0x101b711a0, 0xc005036d50})
    github.com/gohugoio/hugo/commands/server.go:578 +0x4f
github.com/gohugoio/hugo/commands.(*fileServer).createEndpoint.func1.1({0x1024890e0, 0xc003fa6000}, 0xc004951900)
    github.com/gohugoio/hugo/commands/server.go:380 +0x464
net/http.HandlerFunc.ServeHTTP(0xc00523cf00?, {0x1024890e0?, 0xc003fa6000?}, 0x1000125a8?)
    net/http/server.go:2122 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x1024890e0, 0xc003fa6000}, 0xc004951900)
    net/http/server.go:2500 +0x149
net/http.serverHandler.ServeHTTP({0xc005036c90?}, {0x1024890e0, 0xc003fa6000}, 0xc004951900)
    net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc004a34990, {0x10248a5e0, 0xc002a390e0})
    net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
    net/http/server.go:3089 +0x5ed
2023/03/22 23:24:57 http: panic serving 127.0.0.1:65097: runtime error: invalid memory address or nil pointer dereference
goroutine 23845 [running]:
net/http.(*conn).serve.func1()
    net/http/server.go:1854 +0xbf
panic({0x101b84aa0, 0x1034c0460})
    runtime/panic.go:890 +0x263
github.com/gohugoio/hugo/commands.(*commandeer).serve.func1(0xc005f52000?)
    github.com/gohugoio/hugo/commands/server.go:562 +0x32
github.com/gohugoio/hugo/commands.(*commandeer).serve.func2({0x101b711a0, 0xc005036e40})
    github.com/gohugoio/hugo/commands/server.go:578 +0x4f
github.com/gohugoio/hugo/commands.(*fileServer).createEndpoint.func1.1({0x1024890e0, 0xc003fa60e0}, 0xc004154900)
    github.com/gohugoio/hugo/commands/server.go:380 +0x464
net/http.HandlerFunc.ServeHTTP(0xc00664e500?, {0x1024890e0?, 0xc003fa60e0?}, 0x1000125a8?)
    net/http/server.go:2122 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x1024890e0, 0xc003fa60e0}, 0xc004154900)
    net/http/server.go:2500 +0x149
net/http.serverHandler.ServeHTTP({0xc0047caa20?}, {0x1024890e0, 0xc003fa60e0}, 0xc004154900)
    net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc00303e090, {0x10248a5e0, 0xc002a390e0})
    net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
    net/http/server.go:3089 +0x5ed
2023/03/22 23:24:57 http: panic serving 127.0.0.1:65096: runtime error: invalid memory address or nil pointer dereference
goroutine 23844 [running]:
net/http.(*conn).serve.func1()
    net/http/server.go:1854 +0xbf
panic({0x101b84aa0, 0x1034c0460})
    runtime/panic.go:890 +0x263
github.com/gohugoio/hugo/commands.(*commandeer).serve.func1(0xc005f52000?)
    github.com/gohugoio/hugo/commands/server.go:562 +0x32
github.com/gohugoio/hugo/commands.(*commandeer).serve.func2({0x101b711a0, 0xc005036f60})
    github.com/gohugoio/hugo/commands/server.go:578 +0x4f
github.com/gohugoio/hugo/commands.(*fileServer).createEndpoint.func1.1({0x1024890e0, 0xc003fa62a0}, 0xc004154800)
    github.com/gohugoio/hugo/commands/server.go:380 +0x464
net/http.HandlerFunc.ServeHTTP(0xc00664e380?, {0x1024890e0?, 0xc003fa62a0?}, 0x1000125a8?)
    net/http/server.go:2122 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x1024890e0, 0xc003fa62a0}, 0xc004154800)
    net/http/server.go:2500 +0x149
net/http.serverHandler.ServeHTTP({0xc0047ca960?}, {0x1024890e0, 0xc003fa62a0}, 0xc004154800)
    net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc00303e000, {0x10248a5e0, 0xc002a390e0})
    net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
    net/http/server.go:3089 +0x5ed

What version of Hugo are you using (hugo version)?

$ hugo env
hugo v0.111.3+extended darwin/amd64 BuildDate=unknown
GOOS="darwin"
GOARCH="amd64"
GOVERSION="go1.20.2"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.2.4"
github.com/sass/dart-sass-embedded/protocol="1.2.0"
github.com/sass/dart-sass-embedded/compiler="1.59.3"
github.com/sass/dart-sass-embedded/implementation="1.59.3"

Does this issue reproduce with the latest release?

Yes

willfaught commented 1 year ago

Another, different panic when changing branches:

Change detected, rebuilding site.
2023-03-29 21:04:22.342 -0700
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/_index.md"
Template changed CREATE        "/Users/Will/Developer/paige/layouts/partials/paige/img.html"
Template changed CREATE        "/Users/Will/Developer/paige/layouts/shortcodes/paige/image.html"
Total in 126 ms
Rebuilt in 250 ms
panic: runtime error: index out of range [0] with length 0

goroutine 3593 [running]:
github.com/gohugoio/hugo/hugolib.(*pageState).shiftToOutputFormat(0xc0065dae70, 0x1, 0x0)
    github.com/gohugoio/hugo/hugolib/page.go:890 +0x450
github.com/gohugoio/hugo/hugolib.(*pageState).initOutputFormat(...)
    github.com/gohugoio/hugo/hugolib/page.go:486
github.com/gohugoio/hugo/hugolib.(*Site).preparePagesForRender.func1(0xc004d35340?)
    github.com/gohugoio/hugo/hugolib/hugo_sites.go:853 +0x2a
github.com/gohugoio/hugo/hugolib.(*pageMap).withEveryBundlePage.func1({0xc0065da480?, 0x100d24801?}, 0x0?)
    github.com/gohugoio/hugo/hugolib/content_map_page.go:691 +0x2a
github.com/gohugoio/hugo/hugolib.contentTrees.Walk.func1({0xc00586ddd0?, 0x1011b0c89?}, {0x101b49da0?, 0xc003c37b30?})
    github.com/gohugoio/hugo/hugolib/content_map.go:876 +0x3b
github.com/armon/go-radix.recursiveWalk(0xc003c37b90, 0xc004d35508)
    github.com/armon/go-radix@v1.0.0/radix.go:519 +0x45
github.com/armon/go-radix.recursiveWalk(0xc003c37aa0?, 0xc004d35508)
    github.com/armon/go-radix@v1.0.0/radix.go:525 +0xa6
github.com/armon/go-radix.recursiveWalk(0xc0005aac78?, 0xc004d35508)
    github.com/armon/go-radix@v1.0.0/radix.go:525 +0xa6
github.com/armon/go-radix.recursiveWalk(0xc0084ac6c0?, 0xc004d35508)
    github.com/armon/go-radix@v1.0.0/radix.go:525 +0xa6
github.com/armon/go-radix.recursiveWalk(0x3?, 0xc004d35508)
    github.com/armon/go-radix@v1.0.0/radix.go:525 +0xa6
github.com/armon/go-radix.recursiveWalk(0xc006cd8a00?, 0xc004d35508)
    github.com/armon/go-radix@v1.0.0/radix.go:525 +0xa6
github.com/armon/go-radix.(*Tree).Walk(...)
    github.com/armon/go-radix@v1.0.0/radix.go:447
github.com/gohugoio/hugo/hugolib.contentTrees.Walk({0xc003314980, 0x4, 0xd0?}, 0xc004d35548)
    github.com/gohugoio/hugo/hugolib/content_map.go:874 +0x5b
github.com/gohugoio/hugo/hugolib.(*pageMap).withEveryBundlePage(0xc00006a900?, 0xc006cec270?)
    github.com/gohugoio/hugo/hugolib/content_map_page.go:689 +0x47
github.com/gohugoio/hugo/hugolib.(*Site).preparePagesForRender(0x10355e880?, 0x0?, 0xc0001a4008?)
    github.com/gohugoio/hugo/hugolib/hugo_sites.go:852 +0x5e
github.com/gohugoio/hugo/hugolib.(*HugoSites).render(0xc0093d89c0, 0xc002e2b220)
    github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:307 +0x566
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func4()
    github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:146 +0x2a
runtime/trace.WithRegion({0x10248a5e0?, 0xc00882aed0?}, {0x101debbd1, 0x6}, 0xc004d358e8)
    runtime/trace/annotation.go:141 +0xe3
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build(0xc0093d89c0, {0x0, {0x0, 0x0}, 0x0, 0x0, 0x0, 0x0, 0xc00882aea0, 0x0, ...}, ...)
    github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:148 +0x5f3
github.com/gohugoio/hugo/commands.(*commandeer).rebuildSites(0xc00084aa00, {0xc0090afe00?, 0x6?, 0x8?})
    github.com/gohugoio/hugo/commands/hugo.go:766 +0x346
github.com/gohugoio/hugo/commands.(*commandeer).handleEvents.func4(0xc00084aa00, 0xc005451680)
    github.com/gohugoio/hugo/commands/hugo.go:1162 +0x96
github.com/gohugoio/hugo/commands.(*commandeer).handleEvents(0xc00084aa00, 0xc003fc47e0, 0xc0044d1fc8, {0xc0086ae3c0?, 0x6, 0x8}, 0xc001a4a170?)
    github.com/gohugoio/hugo/commands/hugo.go:1165 +0x13be
github.com/gohugoio/hugo/commands.(*commandeer).newWatcher.func1()
    github.com/gohugoio/hugo/commands/hugo.go:896 +0x24b
created by github.com/gohugoio/hugo/commands.(*commandeer).newWatcher
    github.com/gohugoio/hugo/commands/hugo.go:887 +0x4ca