Skip to content

Commit f740d7c

Browse files
committed
Fix panic when 404 is backed by a content file
Fixes #14283
1 parent 5f46da6 commit f740d7c

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

‎hugolib/404_test.go‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,24 @@ Not found.
9292

9393
b.AssertFileContent("public/404.html", `Not found. Updated.`)
9494
}
95+
96+
func Test404Panic14283(t *testing.T) {
97+
t.Parallel()
98+
99+
files := `
100+
-- hugo.toml --
101+
baseURL = "http://example.com/"
102+
-- layouts/all.html --
103+
All. {{ .Kind }}. {{ .Title }}|
104+
-- content/404/_index.md --
105+
---
106+
title: "404 branch"
107+
---
108+
This is the 404 branch.
109+
110+
`
111+
112+
b := Test(t, files) // panic.
113+
114+
b.AssertFileContent("public/404/index.html", "All. section. 404 branch|")
115+
}

‎hugolib/content_map_page_assembler.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ func (a *allPagesAssembler) doCreatePages(prefix string, depth int) error {
198198
p := newHomePageMetaSource()
199199
treePages.InsertRaw(p.pathInfo.Base(), p)
200200
}
201+
201202
}
202203

203204
getCascades := func(wctx *doctree.WalkContext[contentNode], s string) *page.PageMatcherParamsConfigs {

‎hugolib/doctree/nodeshifttree.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ func (r *NodeShiftTreeWalker[T]) toT(tree *NodeShiftTree[T], v T) (T, bool) {
625625
}
626626

627627
func (r *NodeShiftTree[T]) Has(s string) bool {
628-
_, ok := r.get(s)
628+
_, ok := r.GetRaw(s)
629629
return ok
630630
}
631631

0 commit comments

Comments
 (0)