Updating from V0.48 to V0.49 broke build

After updating to v0.49, running hugo serve failed. The errors were of the kind :
Failed to render "people/single.html": reflect.AppendSlice: interface {} != map[string]interface {}
There were like 10 errors, all related to what was inside my /layouts folder. I could get the build to run by removing the files that appeared in the errors, but then all my pages were blank.
The most basic page I had to remove was:
{{ define "main" }} <div> Some static html for my 404 page </div> {{ end }}
and this was located at layouts/404.html. I must add that there is a pretty big _default/baseof.html file, but I could get the build to run without changing it.
What am I doing wrong ?
I’m guessing it has to do with the update on page bundles in v0.49, but I don’t know what’s wrong. Also, reflect.AppendSlice: interface {} != map[string]interface {} seems like a Go error about types, but my only Go knowledge is what I learnt building hugo sites, so I don’t know how to understand it.
Could someone explain me ?
Thanks

I did run into the same problem. There is a GitHub issue for this: https://github.com/gohugoio/hugo/issues/5269

This is my mistake and I will fix it. But would it be possible to see your failing template code? What are you calling when this fails? slice?

Hi and thanks for the quick feedback.
I reinstalled v0.49 from the .deb package (i’m running on Ubuntu 16.04) and tried to locate where I was using slice in my templates. I located one place in a partial used to generate the menu bar, removed it, and my code ran again with v0.49.
Here is the code snippet that was problematic:

{{- $.Scratch.Set "submenu" slice -}}
{{- $.Scratch.Add "submenuHas" "" -}}

{{- range .Site.Params.menu.main -}}
{{- if not .identifier -}}
{{- $.Scratch.Add "submenu" (slice .) -}}
{{- end -}}
{{- end -}}

Behavior : It’s pretty weird because in the snippet above you can see that the slice function is being used twice. Whenever there is only once slice call made the build succeds. It does not depend on which one I remove, as log as I only use slice once.

Hope that helps.

If anyone wonders, it’s used to generate the submenus for this site.

But note that the scratch constructs with Add should now be possible to write cleaner with append.

1 Like