Builds fine on 0.44. Fails with 0.45 both locally on Netlify.
> C:/src/Hugo/bin/hugo.exe server -D --disableFastRender
Building sites … ERROR 2018/07/23 17:25:33 Failed to render "_default/list.algolia.json": runtime error: invalid memory address or nil pointer dereference
ERROR 2018/07/23 17:25:33 Stack Trace:
goroutine 735 [running]:
github.com/gohugoio/hugo/hugolib.stackTrace(0x4b0, 0xf14a71, 0x17)
/go/src/github.com/gohugoio/hugo/hugolib/page.go:280 +0x7d
github.com/gohugoio/hugo/hugolib.(*Site).renderForLayouts.func1(0xc0463d58a0, 0xc0423b4600)
/go/src/github.com/gohugoio/hugo/hugolib/site.go:1742 +0x13c
panic(0xddca80, 0x15af010)
/usr/local/go/src/runtime/panic.go:502 +0x237
text/template.errRecover(0xc0463d57d8)
/usr/local/go/src/text/template/exec.go:137 +0x1db
panic(0xddca80, 0x15af010)
/usr/local/go/src/runtime/panic.go:502 +0x237
github.com/gohugoio/hugo/hugolib.(*Page).IsDescendant(0xc043316500, 0xec0d00, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/gohugoio/hugo/hugolib/site_sections.go:89 +0x58
reflect.Value.call(0xec0d00, 0xc043316500, 0x6213, 0xec6a2b, 0x4, 0xc04a52ba20, 0x1, 0x1, 0xebb520, 0xde4601, ...)
/usr/local/go/src/reflect/value.go:447 +0x970
reflect.Value.Call(0xec0d00, 0xc043316500, 0x6213, 0xc04a52ba20, 0x1, 0x1, 0x10a3d00, 0xc0424d0ea0, 0xec0d00)
/usr/local/go/src/reflect/value.go:308 +0xab
text/template.(*state).evalCall(0xc0478cf758, 0xec0d00, 0xc043e13500, 0x196, 0xec0d00, 0xc043316500, 0x6213, 0x10a3d00, 0xc0424d0e70, 0xc0424a3b25, ...)
/usr/local/go/src
Total in 796 ms
Error: Error building site: logged 2 error(s)
Source is here:
{{/* Generates a valid Algolia search index */}}
{{/* @see https://forestry.io/blog/search-with-algolia-in-hugo/ */}}
{{- $hits := slice -}}
{{- $section := $.Site.GetPage "section" .Section }}
{{- $validVars := $.Param "algolia.vars" | default slice -}}
{{- $validParams := $.Param "algolia.params" | default slice -}}
{{- range $i, $hit := .Site.AllPages -}}
{{- $dot := . -}}
{{- if or (and ($hit.IsDescendant $section) (and (not $hit.Draft) (not $hit.Params.private))) $section.IsHome -}}
{{/* Set the hit's objectID */}}
{{- .Scratch.SetInMap $hit.File.Path "objectID" $hit.UniqueID -}}
{{/* Store built-in page variables in iterable object */}}
{{- .Scratch.SetInMap "temp" "content" $hit.Plain -}}
{{- .Scratch.SetInMap "temp" "date" $hit.Date.UTC.Unix -}}
{{- .Scratch.SetInMap "temp" "description" $hit.Description -}}
{{- .Scratch.SetInMap "temp" "dir" $hit.Dir -}}
{{- .Scratch.SetInMap "temp" "path" "temp" -}}
{{- .Scratch.SetInMap "temp" "expirydate" $hit.ExpiryDate.UTC.Unix -}}
{{- .Scratch.SetInMap "temp" "path" "temp" -}}
{{- .Scratch.SetInMap "temp" "fuzzywordcount" $hit.FuzzyWordCount -}}
This file has been truncated. show original
Join the club!
See here for a possible workaround: Panic Error with .GetPage in Hugo 0.45
But this is also a bug (read further down that topic).
2 Likes
Argh! Annoying. Hopefully someone can put a more meaningful error message on that at some point. I’d have never found that, thanks. I will give the workaround a go now.
I believe that’s a Go limitation… If some function has nil as an argument, it goes crazy (I’m 100% sure that statement is technically incorrect :P). But I have seen this many times in different contexts, and the rule of the thumb is: Use with
– Don’t assume your function arguments to be non-nil.
Already open issue to track stracktrace due to nil
Ref
Well, I couldn’t get the workaround to work in my case. Probably my brain is fried in this heat.
So I’ve killed off the offending template which was supposed to be creating a search JSON file for Algolia but I haven’t managed to get Algolia search to work anyway. A job for another time.