Hello,
I tried building the latest hugo from the master branch, but l see the draft=true crash happening if a branch bundle _index.md content file has draft=true.
Here's one such example content file: https://gitlab.com/kaushalmodi/kaushalmodi.gitlab.io/blob/crash-hugo-v57-draft-branch-bundle/content/series/gujarati-in-emacs/_index.md
git clone --recurse-submodules --single-branch --branch crash-hugo-v57-draft-branch-bundle https://gitlab.com/kaushalmodi/kaushalmodi.gitlab.io scripter.cocd scripter.cohugoBuilding sites … ERROR 2019/08/15 11:39:41 [BUG] Got panic:
goroutine 128 [running]:
runtime/debug.Stack(0x14b7f20, 0xc002a228b0, 0xc002af9508)
/home/kmodi/go/src/runtime/debug/stack.go:24 +0x9d
github.com/gohugoio/hugo/hugolib.newPageContentOutput.func1.1.1(0xc002af9c00, 0xc0011ddb60)
/home/kmodi/downloads/git/hugo/hugolib/page__per_output.go:74 +0x109
panic(0x1486d20, 0x2627580)
/home/kmodi/go/src/runtime/panic.go:522 +0x1b5
github.com/gohugoio/hugo/hugolib.pageContent.contentToRender(0x1, 0x0, 0x0, 0x0, 0x0, 0xc000a55f80, 0x0, 0x19ee8c0, 0xc001260750, 0xdf, ...)
/home/kmodi/downloads/git/hugo/hugolib/page__content.go:49 +0xba
github.com/gohugoio/hugo/hugolib.newPageContentOutput.func1.1(0x19de920, 0xc002a228b0)
/home/kmodi/downloads/git/hugo/hugolib/page__per_output.go:90 +0x1e3
github.com/gohugoio/hugo/hugolib.newPageContentOutput.func1.3(0x14fada0, 0xc00239c430, 0x14f8640, 0xc002af9c68)
/home/kmodi/downloads/git/hugo/hugolib/page__per_output.go:170 +0x26
github.com/gohugoio/hugo/lazy.(*Init).Do.func1()
/home/kmodi/downloads/git/hugo/lazy/init.go:97 +0x139
github.com/gohugoio/hugo/lazy.(*onceMore).Do(0xc000cbc088, 0xc002af9cb8)
/home/kmodi/downloads/git/hugo/lazy/once.go:53 +0xf0
github.com/gohugoio/hugo/lazy.(*Init).Do(0xc000cbc060, 0x8, 0x203000, 0x203000, 0x1457ba0)
/home/kmodi/downloads/git/hugo/lazy/init.go:79 +0x5b
github.com/gohugoio/hugo/hugolib.(*Site).initInit(0xc00046b880, 0xc000cbc060, 0x19fa900, 0xc0011ddb60)
/home/kmodi/downloads/git/hugo/hugolib/site.go:181 +0x2b
github.com/gohugoio/hugo/hugolib.(*pageContentOutput).Content(0xc000cb84e0, 0xc000a9b380, 0x43d9c4, 0x140b2a0, 0x28)
/home/kmodi/downloads/git/hugo/hugolib/page__per_output.go:233 +0x5a
reflect.Value.call(0x1638dc0, 0xc0011ddb60, 0x1e13, 0x163faee, 0x4, 0x2674e30, 0x0, 0x0, 0xc00173b300, 0xc002afa160, ...)
/home/kmodi/go/src/reflect/value.go:447 +0x461
reflect.Value.Call(0x1638dc0, 0xc0011ddb60, 0x1e13, 0x2674e30, 0x0, 0x0, 0x443abc, 0x0, 0x162f0e0)
/home/kmodi/go/src/reflect/value.go:308 +0xa4
text/template.safeCall(0x1638dc0, 0xc0011ddb60, 0x1e13, 0x2674e30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/home/kmodi/go/src/text/template/funcs.go:293 +0xb6
text/template.(*state).evalCall(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0x1638dc0, 0xc0011ddb60, 0x1e13, 0x1a08d80, 0xc00075a810, 0xc0002158ac, ...)
/home/kmodi/go/src/text/template/exec.go:703 +0x68c
text/template.(*state).evalField(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc0002158ac, 0x7, 0x1a08d80, 0xc00075a810, 0xc000815d00, 0x1, ...)
/home/kmodi/go/src/text/template/exec.go:593 +0xd61
text/template.(*state).evalFieldChain(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0x1638dc0, 0xc0011ddb60, 0x16, 0x1a08d80, 0xc00075a810, 0xc000815cf0, ...)
/home/kmodi/go/src/text/template/exec.go:554 +0x220
text/template.(*state).evalFieldNode(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc00075a810, 0xc000815d00, 0x1, 0x1, 0x14870e0, 0x2674e30, ...)
/home/kmodi/go/src/text/template/exec.go:518 +0x114
text/template.(*state).evalCommand(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc00075a7e0, 0x14870e0, 0x2674e30, 0x99, 0x26761a0, 0x3, ...)
/home/kmodi/go/src/text/template/exec.go:456 +0x7a8
text/template.(*state).evalPipeline(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc000756960, 0xc000758500, 0x13eb5c0, 0x26761a0)
/home/kmodi/go/src/text/template/exec.go:430 +0x11c
text/template.(*state).evalArg(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0x1a41180, 0x1454360, 0x1a08f00, 0xc000756960, 0x13eb5c0, 0x26761a0, ...)
/home/kmodi/go/src/text/template/exec.go:785 +0x7b9
text/template.(*state).evalCall(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0x144d220, 0xc0006e2040, 0x13, 0x1a08d00, 0xc00075a780, 0xc0002158a4, ...)
/home/kmodi/go/src/text/template/exec.go:678 +0x280
text/template.(*state).evalFunction(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc00075a7b0, 0x1a08d00, 0xc00075a780, 0xc000758600, 0x3, 0x4, ...)
/home/kmodi/go/src/text/template/exec.go:564 +0x170
text/template.(*state).evalCommand(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc00075a780, 0x14870e0, 0x2674e30, 0x99, 0xc002abe000, 0x7fd0e5c2d460, ...)
/home/kmodi/go/src/text/template/exec.go:461 +0x66c
text/template.(*state).evalPipeline(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc000756900, 0xc0019b80c0, 0x20, 0x18)
/home/kmodi/go/src/text/template/exec.go:430 +0x11c
text/template.(*state).evalArg(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0x1a41180, 0x162f0e0, 0x1a08f00, 0xc000756900, 0x1454360, 0xc00208b7d0, ...)
/home/kmodi/go/src/text/template/exec.go:785 +0x7b9
text/template.(*state).evalCall(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0x14247a0, 0xc0006e2160, 0x13, 0x1a08d00, 0xc00075a720, 0xc00021589f, ...)
/home/kmodi/go/src/text/template/exec.go:678 +0x280
text/template.(*state).evalFunction(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc00075a750, 0x1a08d00, 0xc00075a720, 0xc00065a640, 0x2, 0x2, ...)
/home/kmodi/go/src/text/template/exec.go:564 +0x170
text/template.(*state).evalCommand(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc00075a720, 0x14870e0, 0x2674e30, 0x99, 0xc00021d180, 0x334, ...)
/home/kmodi/go/src/text/template/exec.go:461 +0x66c
text/template.(*state).evalPipeline(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc0007568a0, 0x465c1a, 0x26280c0, 0xc00304a980)
/home/kmodi/go/src/text/template/exec.go:430 +0x11c
text/template.(*state).evalCommand(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc00075a6f0, 0x14870e0, 0x2674e30, 0x99, 0xc002afb2d0, 0x59d3a5, ...)
/home/kmodi/go/src/text/template/exec.go:464 +0x8f0
text/template.(*state).evalPipeline(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc000756840, 0x0, 0x0, 0x98)
/home/kmodi/go/src/text/template/exec.go:430 +0x11c
text/template.(*state).walk(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0x1a08c00, 0xc00075a8a0)
/home/kmodi/go/src/text/template/exec.go:254 +0x49c
text/template.(*state).walk(0xc002afb470, 0x1638dc0, 0xc0011ddb60, 0x16, 0x1a08e40, 0xc00075a4e0)
/home/kmodi/go/src/text/template/exec.go:262 +0x143
text/template.(*state).walkTemplate(0xc002afb650, 0x1638dc0, 0xc0011ddb60, 0x16, 0xc000848b40)
/home/kmodi/go/src/text/template/exec.go:412 +0x222
text/template.(*state).walk(0xc002afb650, 0x1638dc0, 0xc0011ddb60, 0x16, 0x1a08fc0, 0xc000848b40)
/home/kmodi/go/src/text/template/exec.go:267 +0x206
text/template.(*state).walk(0xc002afb650, 0x1638dc0, 0xc0011ddb60, 0x16, 0x1a08e40, 0xc000847bc0)
/home/kmodi/go/src/text/template/exec.go:262 +0x143
text/template.(*Template).execute(0xc0008f7480, 0x19de600, 0xc0043f8540, 0x1638dc0, 0xc0011ddb60, 0x0, 0x0)
/home/kmodi/go/src/text/template/exec.go:217 +0x1e8
text/template.(*Template).Execute(...)
/home/kmodi/go/src/text/template/exec.go:200
html/template.(*Template).Execute(0xc0006d2450, 0x19de600, 0xc0043f8540, 0x1638dc0, 0xc0011ddb60, 0x19eea80, 0xc002edf1d0)
/home/kmodi/go/src/html/template/template.go:122 +0x8d
github.com/gohugoio/hugo/tpl.(*TemplateAdapter).Execute(0xc002edf1d0, 0x19de600, 0xc0043f8540, 0x1638dc0, 0xc0011ddb60, 0x0, 0x0)
/home/kmodi/downloads/git/hugo/tpl/template.go:163 +0xaf
github.com/gohugoio/hugo/hugolib.(*Site).renderForLayouts(0xc00046b880, 0x1653087, 0x8, 0x163fc66, 0x4, 0x1638dc0, 0xc0011ddb60, 0x19de600, 0xc0043f8540, 0xc00157fc00, ...)
/home/kmodi/downloads/git/hugo/hugolib/site.go:1597 +0xb8
github.com/gohugoio/hugo/hugolib.(*Site).renderAndWritePage(0xc00046b880, 0xc0002ef410, 0xc001cd8190, 0x4a, 0xc000ca8f60, 0x24, 0xc0011ddb60, 0xc00157fc00, 0x24, 0x40, ...)
/home/kmodi/downloads/git/hugo/hugolib/site.go:1513 +0x1ce
github.com/gohugoio/hugo/hugolib.pageRenderer(0xc0014eb840, 0xc00046b880, 0xc000cbc2a0, 0xc0006949c0, 0xc000f8b680)
/home/kmodi/downloads/git/hugo/hugolib/site_render.go:152 +0x5f2
created by github.com/gohugoio/hugo/hugolib.(*Site).renderPages
/home/kmodi/downloads/git/hugo/hugolib/site_render.go:73 +0x160
Total in 4117 ms
Error: Error building site: "/home/kmodi/temp/scripter.co/content/series/gujarati-in-emacs/_index.md:1:1": runtime error: invalid memory address or nil pointer dereference
What do you mean by "still happens"? Do you have a link to an exstisting issue?
What do you mean by "still happens"?
I meant that the earlier commit ( https://github.com/gohugoio/hugo/commit/9475f61a377fcf23f910cbfd4ddca59261326665 ) that fixed https://github.com/gohugoio/hugo/issues/6213 did not fix the draft=true crash in _index.md for taxonomy _Kind_ pages.
I have removed "still" from bug title.
To answer your question: We don't support "draft" (or expired etc.) for _index.md files. We should not fail this drastically, that's true. And my recent commit helped get a good stack trace.
We don't support "draft" (or expired etc.) for _index.md files.
I have explained a real use case scenario on the forum where I found the draft of _index.md files very useful (that feature unknowingly has been working great so far!)
For convenience:
I am preparing a landing page for an XYZ series taxonomy for a not-yet published posts from that series. So I have the _index.md for that XYZ series taxonomy marked as draft too. I wouldn’t want the landing page to be published even before I have the posts in that series ready.
Please consider supporting this.
Please consider supporting this.
We can probably implement it, but there's not a single test covering this, and I'm not sure what's going to happen with the pages in the section if you "draft" the owner etc.
I'm not sure what's going to happen with the pages in the section if you "draft" the owner etc.
I believe the pages with drafted _index.md will have the usual list page rendered using the default list.html template (considering a common scenario where user has _default/single.html and _default.list.html. As _index.md will be drafted, the .Content for that list page will be empty.
The other pages and leaf/branch bundles in that taxonomy section will render as usual.
there's not a single test covering this
If you do not mind, please add the _index.md presented at the top as a new test case.
As _index.md will be drafted, the .Content for that list page will be empty.
Draft means more than that, it means "don't publish this page" (there is content and other metadata).
@regisphilibert is this related to your crash?
Draft means more than that, it means "don't publish this page" (there is content and other metadata).
I agree, but as far as I knew, the content of draft pages is inaccessible (so I probably misrepresented as "empty").
As an additional data point, hugo crashes, but hugo server does not.
I will need to think about this. But this issue at least helped me fix a stupid crash.
@kaushalmodi my short term fix for this (will commit in a few) will, I think, be somewhat in line with what you want. We may revisit this later with a "better spec".
@regisphilibert is this related to your crash?
Yep, we had a drafted section in there, undrafting it fixed the pb.
I'm aligned with @kaushalmodi as in I need to be able to draft sections.
I confirm the fix in https://github.com/gohugoio/hugo/pull/6224 (that the crash does not happen any more, and also the draft=true in the _index.md is also respected). Thanks!
Most helpful comment
I confirm the fix in https://github.com/gohugoio/hugo/pull/6224 (that the crash does not happen any more, and also the
draft=truein the_index.mdis also respected). Thanks!