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

hugo build: warning '.File.UniqueID on zero object' #1007

Closed
deining opened this issue May 9, 2022 · 5 comments · Fixed by #1633
Closed

hugo build: warning '.File.UniqueID on zero object' #1007

deining opened this issue May 9, 2022 · 5 comments · Fixed by #1633
Milestone

Comments

@deining
Copy link
Collaborator

deining commented May 9, 2022

How to reproduce

  • Create a new site from scratch as described here.
  • Create a new page inside the docs folder: hugo new content/docs/_index.md
  • Run hugo -D and you will get this warning:
hugo v0.98.0-165d299cde259c8b801abadc6d3405a229e449f6+extended windows/amd64 BuildDate=2022-04-28T10:23:30Z VendorInfo=gohugoio
WARNING: calling IsSet with unsupported type "invalid" (<nil>) will always return false.
WARN 2022/05/09 09:57:25 .File.UniqueID on zero object. Wrap it in if or with: {{ with .File }}{{ .UniqueID }}{{ end }}

Using hugo --panicOnWarning, you can track down where the error originates:

Error: Error building site: failed to render pages: render of "section" failed:
execute of template failed: template: docs/list.html:12:11:
executing "main" at <partial "section-index.html" .>
: error calling partial: "...\layouts\partials\section-index.html:7:17":
execute of template failed: template: partials/section-index.html:7:17
: executing "partials/section-index.html"
at <where $pages "Parent.File.UniqueID" "==" $parent.File.UniqueID>:
error calling where:
Warning trapped. Remove the --panicOnWarning flag to continue.

So the offending code line is here:

{{ $pages = (where $pages "Parent.File.UniqueID" "==" $parent.File.UniqueID) }}

@LisaFC
Copy link
Collaborator

LisaFC commented May 13, 2022

Let me take a look. That line was from an update in 2021 by someone who doesn't seem to still be on GitHub under that user name, but it didn't break anything at the time....

@richardsuematsu
Copy link

I had the same issue on Node v8. Upgraded to Node v16 and it worked.

@chalin
Copy link
Collaborator

chalin commented Nov 10, 2023

I followed your instructions but can no longer reproduce the error. Hugo 0.120.4 and Node 20. Can you still reproduce the error @deining?

@deining
Copy link
Collaborator Author

deining commented Nov 18, 2023

I followed your instructions but can no longer reproduce the error. Hugo 0.120.4 and Node 20. Can you still reproduce the error @deining?

Yes, I can. Hugo v0.120.4 and Node 16.20.2, Ubuntu 22.04.

Addendum: Just verified, I can reproduce it with latest Node version 20.9.0 too. This was to be expected, I don't think Node version (or node in general) play any role here.

deining added a commit to deining/docsy that referenced this issue Nov 19, 2023
@deining
Copy link
Collaborator Author

deining commented Nov 19, 2023

Oops, my description how to reproduce the error was imprecise, it is corrected now:
New content is disabled by default, so you have to run hugo --buildDrafts in order to be confronted with the error.
@chalin: pretty sure you can see the error once you run hugo -D.

@chalin chalin added this to the 23Q4 milestone Nov 29, 2023
deining added a commit to deining/docsy that referenced this issue Dec 31, 2023
@chalin chalin modified the milestones: 23Q4, 24Q1 Jan 11, 2024
chalin pushed a commit to deining/docsy that referenced this issue Jan 15, 2024
deining added a commit to deining/docsy that referenced this issue Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants