fix(links): prevent nil-map panic in build_links on Hugo >= 0.162 - #3329
fix(links): prevent nil-map panic in build_links on Hugo >= 0.162#3329Vidminas wants to merge 1 commit into
Conversation
Hugo 0.162 changed `dict` so that an empty `(dict)` returns a non-writable nil map. build_links pre-seeded its dedup set with `$seen.Set "set" (dict)` and then wrote to it via `$seen.SetInMap "set" ...`. Because the Scratch key already existed, SetInMap skipped its internal make() and assigned straight into the nil map, panicking with "assignment to entry in nil map" while rendering any page that emits a link. Drop the pre-seed; SetInMap creates a writable map on first use, which is correct on every Hugo version. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Deploy Preview for academic-demo canceled.
|
|
Wow, your first PR! Welcome to the community! 🎉 Thank you for this contribution to open source and open research. It makes a huge impact for the thousands of innovators building with Hugo Blox. If you're wondering about next steps, please read our Contributor Guide for coding standards, how to run the project locally, and how to get help. We hope this is just the start of your journey with us. Let's build the future together! Join us on Discord to connect with the team and community. Awesome work, we'll take a look soon! ✨ |
|
This PR is stale because it has not had any recent activity. The resources of the project maintainers are limited, and so we are asking for your help. If you feel that the PR is still relevant in the latest release, consider making the PR easier to review and finding developers to help review the PR. Please be mindful that although we encourage PRs, we cannot expand the scope of the project in every possible direction. There will be requests that don't make the roadmap. This PR will automatically close soon if no further activity occurs. Thank you for your contributions. |
|
This is still relevant, keep open ^ |
Hugo 0.162 changed
dictso that an empty(dict)returns a non-writable nil map. build_links pre-seeded its dedup set with$seen.Set "set" (dict)and then wrote to it via$seen.SetInMap "set" .... Because the Scratch key already existed, SetInMap skipped its internal make() and assigned straight into the nil map, panicking with "assignment to entry in nil map" while rendering any page that emits a link.Drop the pre-seed; SetInMap creates a writable map on first use, which is correct on every Hugo version.
🚀 What type of change is this?
🎯 What is the purpose of this change?
Fixes a total build failure on Hugo ≥ 0.162.0. Any site that renders a page with links
(portfolio items, publications, anything using
page_links/ thecitationview / theciteshortcode) aborts the build with:
Full CI log:
Details
Root cause. Hugo 0.162 changed
collections.Dictionaryso that an empty(dict)nowreturns a non-writable nil map (its own comment: "this cannot be written to … If we do,
that's a bug").
build_links.htmlpre-seeded its dedup set with{{ $seen.Set "set" (dict) }}and then wrote to it via
{{ $seen.SetInMap "set" … }}. Because the Scratch keysetalreadyexisted,
Scratch.SetInMapskipped its internalmake(map[string]any)and assigned straightinto the nil map → panic. Hugo ≤ 0.161 was unaffected (there an empty
dictwas writable).Fix (one line). Drop the pre-seed.
SetInMapauto-creates a writable map on first use whenthe key is absent, so the dedup set still works — correct on every Hugo version.
Reproduced the panic and verified the fix by building the
academic-cvstarter on Hugo0.162.0 (fails on
main, 93 pages / exit 0 with this change) and re-checked on 0.161.1.📸 Screenshots or Screencast (if applicable)
n/a — build-time fix (no visual change).
ℹ️ Documentation Check
📜 Contributor Agreement
Thank you for your contribution!