Skip to content

Fix panic on server atomic save edits on MacOS - #15132

Merged
bep merged 1 commit into
gohugoio:masterfrom
bep:fix/panicrename-15130
Jul 26, 2026
Merged

Fix panic on server atomic save edits on MacOS#15132
bep merged 1 commit into
gohugoio:masterfrom
bep:fix/panicrename-15130

Conversation

@bep

@bep bep commented Jul 24, 2026

Copy link
Copy Markdown
Member

An atomic save (write temp file, rename into place) unlinks the inode the
watcher holds, so kqueue reports Remove for a file that's still on disk.
That took the delete branch and wiped the entire taxonomy subtree; the
following assemble then panicked in createMissingTaxonomies, where the
shifting tree.Get hit a not yet assembled *pageMetaSource.

Treat Remove of a path that still exists as an update, and use the
non-shifting GetRaw when checking for the auto created taxonomy node.

Fixes #15130

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@bep
bep force-pushed the fix/panicrename-15130 branch from 28fa1f0 to c0a111a Compare July 24, 2026 20:07
@bep
bep requested a review from Copilot July 25, 2026 16:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a hugo server rebuild panic on macOS/kqueue triggered by atomic-save editor behavior (temp write + rename-over), ensuring file watcher events don’t incorrectly delete taxonomy subtrees and that taxonomy creation checks don’t shift unassembled nodes.

Changes:

  • Treat fsnotify.Remove/Rename as an update when the path still exists (atomic-save behavior on macOS/kqueue).
  • Avoid shifting during rebuild taxonomy checks by using GetRaw, and add integration coverage for atomic-save rebuild scenarios.
  • Refactor content-node helpers (seq conversions / auto-node detection) and move contentWeight logic into pageMetaSource.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
hugolib/site.go Reclassifies Remove/Rename events as “removed” only when Stat fails, preventing false deletes on atomic saves.
hugolib/rebuild_test.go Adds rebuild integration tests covering atomic-save edits for section bundles and content-backed taxonomy roots.
hugolib/page.go Delegates pageState.contentWeight() to pageMetaSource.
hugolib/page__meta.go Introduces pageMetaSource.contentWeight() to centralize content weight logic.
hugolib/integrationtest_builder.go Adds test harness support for simulating atomic-save watcher events.
hugolib/content_map_page_contentnodeshifter.go Switches helper calls to the helperContentNode receiver-based APIs.
hugolib/content_map_page_contentnode.go Adds helper methods for seq conversion and auto-node detection, and wires pageMetaSource into weight provider interface.
hugolib/content_map_page_assembler.go Uses GetRaw + auto-node detection to avoid shifting unassembled nodes during rebuild taxonomy creation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hugolib/content_map_page_contentnode.go
Comment thread hugolib/integrationtest_builder.go Outdated
An atomic save (write temp file, rename into place) unlinks the inode the
watcher holds, so kqueue reports Remove for a file that's still on disk.
That took the delete branch and wiped the entire taxonomy subtree; the
following assemble then panicked in createMissingTaxonomies, where the
shifting tree.Get hit a not yet assembled *pageMetaSource.

Treat Remove of a path that still exists as an update, and use the
non-shifting GetRaw when checking for the auto created taxonomy node.

Fixes gohugoio#15130

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bep
bep force-pushed the fix/panicrename-15130 branch from 180ad2e to cde8282 Compare July 26, 2026 09:55
@bep
bep merged commit 6bf1524 into gohugoio:master Jul 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants