Hugo v0.152.0 - Error - error calling Where: unable to convert value to float

Used 0.152 locally while working on some changes to my site; before then I was 0.151.

I’m receiving the following error when I use where in content templates or shortcodes:

ERROR render of "/.../myfile.md" failed: "/.../hugo_cache/modules/filecache/modules/pkg/mod/github.com/imfing/hextra@v0.11.1/layouts/docs/single.html:10:13": execute of template failed: template: docs/single.html:10:13: executing "main" at <.Content>: error calling Content: "/.../myfile.md:59:3": failed to render shortcode "sc": failed to process shortcode: "/.../layouts/_shortcodes/sc.html:65:40": execute of template failed: template: _shortcodes/sc.html:65:40: executing "_shortcodes/sc.html" at <collections.Where>: error calling Where: unable to convert value to float

This appears wherever I’m using where throughout my site. Whether in that shortcode example above, or in a content generation template that generates pages from data.

My data is in YAML format (which makes me wonder if this is related to the change of YAML module in 0.152). In that YAML format, I have data containing integer numbers (e.g. year). I will use that YAML sourced data in a where statement similar to:

...$years is an array of integers retrieved from the same YAML data file...
{{ range (sort $years "value" "desc") }}
{{ with (collections.Where $datafile "year" "eq" $year) }}
   ...content related to the YAML data for that year...
{{ end }}
{{ end }}

That where statement yields no entries, thus failing to generate content.

My shortcode takes an integer argument, and uses that integer in a where statement:

{{- $thing := $ctx.Get "thing" -}}
{{- with index $.Site.Data.datafile $category.name -}}
{{- $exact_thing := collections.Where . "num" "eq" (cast.ToInt $thing) -}}
...output related to exact_thing...
{{ end }}

Basically, every case where I’m using YAML data files and call a where using an integer in comparison, I get this unable to convert value to float error.

I’ve tried to give as much supporting data as possible, but the site/repo is private and unable to be shared. Happy to provide more information if necessary to determine if this is YAML related or not.

Just downgraded to v0.151.2 and confirmed my build works fine. No errors on where calls involving integers from YAML data files.

This will be fixed in a soon to come patch release.

1 Like

Excellent! Thank you!

Confirmed fixed by 0.152.1 release! Thanks!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.