fix(links): prevent nil-map panic in build_links on Hugo >= 0.162#3329
Open
Vidminas wants to merge 1 commit into
Open
fix(links): prevent nil-map panic in build_links on Hugo >= 0.162#3329Vidminas wants to merge 1 commit into
Vidminas 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.
|
Contributor
|
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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!