Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hugo new panics when folder name contains a date #12599

Open
pawelgrzybek opened this issue Jun 15, 2024 · 7 comments
Open

hugo new panics when folder name contains a date #12599

pawelgrzybek opened this issue Jun 15, 2024 · 7 comments

Comments

@pawelgrzybek
Copy link

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

hugo v0.127.0+extended darwin/arm64 BuildDate=2024-06-05T10:27:59Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes


I use leaf bundles for my posts. I infer date of my posts from the folder name. I have this in my config.

[frontmatter]
  date = [':filename', ':default']

Assuming I have this archetype under archetypes/posts/index.md

---
title: "Title goes here"
summary: "Summary goes here."
---

When I run hugo new posts/test it works as expected. If I run a hugo new posts/2024-06-17-test, I am receiving an error.

panic: [BUG] no Page found for "/Users/pawelgrzybek/Sites/pawelgrzybek.com/content/posts/2024-06-17-test/index.md"

goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0x14000b2ccc0, {0x14000b0b200, 0x59}, {0x104034360, 0x14000373140})
	github.com/gohugoio/hugo/create/content.go:273 +0x2b8
github.com/gohugoio/hugo/create.(*contentBuilder).buildDir(0x14000b2ccc0)
	github.com/gohugoio/hugo/create/content.go:179 +0x51c
github.com/gohugoio/hugo/create.NewContent.func1()
	github.com/gohugoio/hugo/create/content.go:92 +0x268
github.com/gohugoio/hugo/create.NewContent(0x140009b6000, {0x0, 0x0}, {0x16f9b3a79, 0x15}, 0x0)
	github.com/gohugoio/hugo/create/content.go:106 +0x480
github.com/gohugoio/hugo/commands.newNewCommand.func1({0x0?, 0x0?}, 0x0?, 0x140008a8c80, {0x140008f1250, 0x0?, 0x0?})
	github.com/gohugoio/hugo/commands/new.go:60 +0x160
github.com/gohugoio/hugo/commands.(*simpleCommand).Run(0x0?, {0x1040292e8?, 0x105475840?}, 0x0?, {0x140008f1250?, 0xa6fa80a000000000?, 0x140008059f8?})
	github.com/gohugoio/hugo/commands/commandeer.go:618 +0x48
github.com/bep/simplecobra.(*Commandeer).compile.func1(0x140006c3000?, {0x140008f1250?, 0x4?, 0x1021ccd37?})
	github.com/bep/simplecobra@v0.4.0/simplecobra.go:113 +0x54
github.com/spf13/cobra.(*Command).execute(0x140008faf08, {0x140008f1210, 0x1, 0x1})
	github.com/spf13/cobra@v1.8.0/command.go:983 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x1400056b208)
	github.com/spf13/cobra@v1.8.0/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
	github.com/spf13/cobra@v1.8.0/command.go:1048
github.com/bep/simplecobra.(*Exec).Execute(0x14000091320, {0x1040292e8?, 0x105475840?}, {0x140002b0a80?, 0x103bb7e40?, 0x100496028?})
	github.com/bep/simplecobra@v0.4.0/simplecobra.go:155 +0xb4
github.com/gohugoio/hugo/commands.Execute({0x1400004e4c0, 0x2, 0x2})
	github.com/gohugoio/hugo/commands/commandeer.go:68 +0x284
main.main()
	github.com/gohugoio/hugo/main.go:25 +0x70

Here is a repo where I am facing this issue: https://github.com/pawelgrzybek/pawelgrzybek.com

@jmooring
Copy link
Member

Problem occurs with v0.123.0 and later.

@pawelgrzybek
Copy link
Author

Thanks for confirming that @jmooring

@khayyamsaleem
Copy link
Contributor

Unable to reproduce with v0.128.2

@pawelgrzybek
Copy link
Author

Just tested on v0.128.2 and bug is still there.

~/Sites/pawelgrzybek.com hugo new posts/2024-08-17-test                                                                                                                                                                                                               master:386022ac [•]
panic: [BUG] no Page found for "/Users/pawelgrzybek/Sites/pawelgrzybek.com/content/posts/2024-08-17-test/index.md"

goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0x14000a32d80, {0x14000193da0, 0x51}, {0x10420ff40, 0x14000373740})
	github.com/gohugoio/hugo/create/content.go:273 +0x2b8
github.com/gohugoio/hugo/create.(*contentBuilder).buildDir(0x14000a32d80)
	github.com/gohugoio/hugo/create/content.go:179 +0x51c
github.com/gohugoio/hugo/create.NewContent.func1()
	github.com/gohugoio/hugo/create/content.go:92 +0x268
github.com/gohugoio/hugo/create.NewContent(0x140008d4640, {0x0, 0x0}, {0x16f8efa81, 0x15}, 0x0)
	github.com/gohugoio/hugo/create/content.go:106 +0x480
github.com/gohugoio/hugo/commands.newNewCommand.func1({0x0?, 0x0?}, 0x0?, 0x140004df900, {0x14000481d80, 0x0?, 0x0?})
	github.com/gohugoio/hugo/commands/new.go:60 +0x160
github.com/gohugoio/hugo/commands.(*simpleCommand).Run(0x0?, {0x104204e48?, 0x1056619e0?}, 0x0?, {0x14000481d80?, 0x2edc75d200000000?, 0x14000abf9f8?})
	github.com/gohugoio/hugo/commands/commandeer.go:618 +0x48
github.com/bep/simplecobra.(*Commandeer).compile.func1(0x1400097ce00?, {0x14000481d80?, 0x4?, 0x1022aedfc?})
	github.com/bep/simplecobra@v0.4.0/simplecobra.go:113 +0x54
github.com/spf13/cobra.(*Command).execute(0x140007f2f08, {0x14000481d40, 0x1, 0x1})
	github.com/spf13/cobra@v1.8.0/command.go:983 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x14000967508)
	github.com/spf13/cobra@v1.8.0/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
	github.com/spf13/cobra@v1.8.0/command.go:1048
github.com/bep/simplecobra.(*Exec).Execute(0x1400080ecc8, {0x104204e48?, 0x1056619e0?}, {0x140003e7780?, 0x103d8d7e0?, 0x10055b00c?})
	github.com/bep/simplecobra@v0.4.0/simplecobra.go:155 +0xb4
github.com/gohugoio/hugo/commands.Execute({0x1400019c490, 0x2, 0x2})
	github.com/gohugoio/hugo/commands/commandeer.go:68 +0x284
main.main()
	github.com/gohugoio/hugo/main.go:25 +0x70

@bep bep added this to the v0.130.0 milestone Jul 22, 2024
@bep bep removed the NeedsTriage label Jul 22, 2024
@bep bep modified the milestones: v0.130.0, v0.131.0 Jul 30, 2024
@bep bep modified the milestones: v0.131.0, v0.133.0 Aug 9, 2024
@bep bep modified the milestones: v0.133.0, Unscheduled Aug 29, 2024
@pawelgrzybek
Copy link
Author

@bep I am not sure on which version it was fixed, but the issue is no longer there. I can successfully run hugo new posts/2024-10-25-it-just-woks and it build a new post based on my archetype successfully.

I am not sure if the fix was intentional or implicitly resolved by doing some other changes, so I will leave that with you to close the issue.

Thank you 🤗

@jmooring
Copy link
Member

This has not been fixed. The problem occurs with v0.123.0 and later when the date is in the future. For example:

hugo new posts/2050-12-31-test

@pawelgrzybek
Copy link
Author

You're absolutely right; I hit a false positive because I tested it with today's date. It still fails with the future date, as you said. Thanks for the info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants