Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: drafts throw errors #1141

Closed
davidsneighbour opened this issue Aug 19, 2024 · 1 comment
Closed

bug: drafts throw errors #1141

davidsneighbour opened this issue Aug 19, 2024 · 1 comment
Assignees
Labels
type:bug Bugfixes in codebase when something is not working.

Comments

@davidsneighbour
Copy link
Owner

Lately --- this is not pinnable to a version number, it just stopped working, after August 12th --- I am unable to use hugo server -D due to type casting errors:

hugo server:

❯ hugo server
Watching for changes in /home/patrick/github.com/davidsneighbour/kollitsch.dev/{archetypes,assets,content,data,documentation,i18n,layouts,package.json,postcss.tailwind.config.js,static,tailwind.config.js}
Watching for config changes in /home/patrick/github.com/davidsneighbour/kollitsch.dev/config/_default, /home/patrick/github.com/davidsneighbour/kollitsch.dev/config/development, /home/patrick/github.com/davidsneighbour/kollitsch.dev/go.mod
Start building sites … 
hugo v0.133.0-c9777473d1369f812d727a6c07dc57ad7be7bf62+extended linux/amd64 BuildDate=2024-08-17T19:57:41Z VendorInfo=gohugoio


                   |  EN   
-------------------+-------
  Pages            |  836  
  Paginator pages  |   92  
  Non-page files   |  193  
  Static files     |   67  
  Processed images | 1181  
  Aliases          |  231  
  Cleaned          |    0  

Built in 3609 ms
Environment: "development"
Serving pages from disk
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1) 
Press Ctrl+C to stop

hugo server -D:

❯ hugo server -D
Watching for changes in /home/patrick/github.com/davidsneighbour/kollitsch.dev/{archetypes,assets,content,data,documentation,i18n,layouts,package.json,postcss.tailwind.config.js,static,tailwind.config.js}
Watching for config changes in /home/patrick/github.com/davidsneighbour/kollitsch.dev/config/_default, /home/patrick/github.com/davidsneighbour/kollitsch.dev/config/development, /home/patrick/github.com/davidsneighbour/kollitsch.dev/go.mod
Start building sites … 
hugo v0.130.0-9b1b11c8a59a900458e9e460f197a44367c022ee+extended linux/amd64 BuildDate=2024-07-29T13:51:56Z VendorInfo=gohugoio

Built in 228783 ms
Error: error building site: render: failed to render pages: render of "home" failed: "/home/patrick/github.com/davidsneighbour/kollitsch.dev/layouts/index.html:27:22": execute of template failed: template: index.html:27:22: executing "main" at <partials.Include>: error calling Include: "/home/patrick/github.com/davidsneighbour/kollitsch.dev/layouts/partials/content/post.html:5:31": execute of template failed: template: partials/content/post.html:5:31: executing "partials/content/post.html" at <partials.IncludeCached>: error calling IncludeCached: "/home/patrick/.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/davidsneighbour/hugo-modules/modules/[email protected]/layouts/partials/func/getArticleClasses.html:2:23": execute of template failed: template: partials/func/getArticleClasses.html:2:23: executing "partials/func/getArticleClasses.html" at <.IsHome>: nil pointer evaluating interface {}.IsHome

The template in question is this:

{{- $classes := collections.Slice -}}
{{- if compare.Eq true .IsHome -}}{{/* <-- the error points here */}}
  {{- $classes = $classes | collections.Append "is-home" -}}
{{- end -}}
{{- if compare.Eq true .IsNode -}}
  {{- $classes = $classes | collections.Append "is-node" -}}
{{- end -}}
{{- if compare.Eq true .IsPage -}}
  {{- $classes = $classes | collections.Append "is-page" -}}
{{- end -}}
{{- if compare.Eq true .IsSection -}}
  {{- $classes = $classes | collections.Append (fmt.Printf "section section-%s" .Section ) -}}
{{- end -}}
{{- $classes = $classes | collections.Append (fmt.Printf "kind-%s" .Kind) -}}
{{- $classes = $classes | collections.Append (fmt.Printf "type-%s" .Type) -}}
{{- if compare.Eq true .Draft -}}
  {{- $classes = $classes | collections.Append "draft" -}}
{{- end -}}
{{- $classes = collections.Delimit $classes " " -}}
{{- return $classes -}}

and it worked before, I am pretty sure.

The only thing that changed is the version of Golang in my system (installed via Snap).

Could it be that something changed with the way Hugo works with typecasting? I can change the template by wrapping it with {{ with . }}, but then another template error takes over, this time complaining about another undefined value.

Error: error building site: render: failed to render pages: render of "home" failed: "/home/patrick/github.com/davidsneighbour/kollitsch.dev/layouts/index.html:27:22": execute of template failed: template: index.html:27:22: executing "main" at <partials.Include>: error calling Include: "/home/patrick/github.com/davidsneighbour/kollitsch.dev/layouts/partials/content/post.html:51:18": execute of template failed: template: partials/content/post.html:51:18: executing "partials/content/post.html" at <partials.Include>: error calling Include: "/home/patrick/github.com/davidsneighbour/hugo-modules/modules/hooks/layouts/partials/func/hook.html:37:24": execute of template failed: template: partials/func/hook.html:37:24: executing "partials/func/hook.html" at <partials.Include>: error calling Include: "/home/patrick/github.com/davidsneighbour/kollitsch.dev/layouts/partials/hooks/post-after.html:1:29": execute of template failed: template: partials/hooks/post-after.html:1:29: executing "partials/hooks/post-after.html" at <.context.Params.tags>: nil pointer evaluating interface {}.Params

I tried to minimize the frontmatter of the draft post, to no change. As soon as I have any post with draft: true in it's frontmatter hugo server -D gives up.

Basically trying to use drafts results in my install having issues with undefined values that did not exist before.

@davidsneighbour davidsneighbour added type:bug Bugfixes in codebase when something is not working. state:unconfirmed This issue needs to be reproduced. labels Aug 19, 2024
@davidsneighbour davidsneighbour self-assigned this Aug 19, 2024
@davidsneighbour
Copy link
Owner Author

davidsneighbour commented Aug 19, 2024

See https://discourse.gohugo.io/t/drafts-vs-undefined-values/51219

HUGO
Lately — this is not pinnable to a version number, it just stopped working, after August 12th — I am unable to use hugo server -D due to type casting errors: hugo server: ❯ hugo server Watching for changes in /home/patrick/github.com/davidsneighbour/kollitsch.dev/{archetypes,assets,content,data,documentation,i18n,layouts,package.json,postcss.tailwind.config.js,static,tailwind.config.js} Watching for config changes in /home/patrick/github.com/davidsneighbour/kollitsch.dev/config/_default, /home...

@github-actions github-actions bot removed the state:unconfirmed This issue needs to be reproduced. label Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Bugfixes in codebase when something is not working.
Projects
None yet
Development

No branches or pull requests

1 participant