Skip to content

panic: Shift: unknown type *hugolib.pageMetaSource on server rebuild when a content-backed taxonomy root's _index.md is saved atomically (rename-over) #15130

Description

@Dovizu

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.164.0+extended+withdeploy darwin/arm64

Does this issue reproduce with the latest release?

Yes — reproduces on 0.164.0 (latest) and on 0.162.1. It is only triggered under hugo server (watch mode); a one-shot hugo build is unaffected.

Issue

Under hugo server, saving a branch bundle (_index.md) with an atomic save i.e. write to a temp file, then rename() over the original, panics and kills the server. Atomic saves are the default write strategy for many editors (Nova, and VS Code / Vim / Emacs / GNOME apps under various settings), so this is hit in normal editing, not just by a synthetic test.

Minimal reproduction:

hugo new site repro && cd repro

cat > hugo.toml <<'EOF'
baseURL = 'https://example.org/'
title = 'Repro'
[taxonomies]
  object = 'objects'
EOF

mkdir -p content/objects
printf -- '---\ntitle: Home\n---\n'    > content/_index.md
printf -- '---\ntitle: Objects\n---\n' > content/objects/_index.md   # content-backed taxonomy root

hugo server

Then, in another shell, simulate an editor's atomic save (temp file + rename-over) of the taxonomy root:

cp content/objects/_index.md content/objects/x.tmp && mv content/objects/x.tmp content/objects/_index.md

The running server panics immediately.

What happened instead?

Change detected, rebuilding site (#1).
Source changed /objects/_index.md
panic: Shift: unknown type *hugolib.pageMetaSource for "/objects"

goroutine 7 [running]:
github.com/gohugoio/hugo/hugolib.(*contentNodeShifter).Shift(...)
	github.com/gohugoio/hugo/hugolib/content_map_page_contentnodeshifter.go:160 +0x748
github.com/gohugoio/hugo/hugolib/doctree.(*NodeShiftTree[...]).shift(...)
	github.com/gohugoio/hugo/hugolib/doctree/nodeshifttree.go:653
github.com/gohugoio/hugo/hugolib/doctree.(*NodeShiftTree[...]).get(...)
	github.com/gohugoio/hugo/hugolib/doctree/nodeshifttree.go:664 +0x8c
github.com/gohugoio/hugo/hugolib/doctree.(*NodeShiftTree[...]).Get(...)
	github.com/gohugoio/hugo/hugolib/doctree/nodeshifttree.go:337
github.com/gohugoio/hugo/hugolib.(*allPagesAssembler).createMissingTaxonomies(...)
	github.com/gohugoio/hugo/hugolib/content_map_page_assembler.go:1388 +0x298
github.com/gohugoio/hugo/hugolib.(*allPagesAssembler).createMissingPages(...)
	github.com/gohugoio/hugo/hugolib/content_map_page_assembler.go:1485 +0x20
github.com/gohugoio/hugo/hugolib.(*allPagesAssembler).doCreatePages(...)
	github.com/gohugoio/hugo/hugolib/content_map_page_assembler.go:192 +0x394
github.com/gohugoio/hugo/hugolib.(*allPagesAssembler).createAllPages(...)
	github.com/gohugoio/hugo/hugolib/content_map_page_assembler.go:137 +0xa0
github.com/gohugoio/hugo/hugolib.(*HugoSites).assemble(...)
	github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:345 +0x41c
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build(...)
	github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:187 +0x6c8
github.com/gohugoio/hugo/commands.(*hugoBuilder).rebuildSites(...)
	github.com/gohugoio/hugo/commands/hugobuilder.go:1146 +0x13c
github.com/gohugoio/hugo/commands.(*hugoBuilder).handleEvents(...)
	github.com/gohugoio/hugo/commands/hugobuilder.go:952 +0x1500
github.com/gohugoio/hugo/commands.(*hugoBuilder).newWatcher.func2()
	github.com/gohugoio/hugo/commands/hugobuilder.go:393 +0x1bc
created by github.com/gohugoio/hugo/commands.(*hugoBuilder).newWatcher in goroutine 1
	github.com/gohugoio/hugo/commands/hugobuilder.go:364 +0x408

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions