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

Panic with a misleading error on new page creation. ?When similar page exists? #12602

Open
bryndin opened this issue Jun 16, 2024 · 1 comment
Labels
Milestone

Comments

@bryndin
Copy link

bryndin commented Jun 16, 2024

I already had a content/about dir. Running hugo new content about.md freaks Hugo into panic.

  1. Error message is confusing [BUG] no Page found for "/home/db/projects/blog/content/about.md". Should it say the page exists without panicking? Not sure what is the expected behavior.
  2. The command did create about.md before failing (the timestamp matches the command execution time, see the prompt timer). Why did it make it if the about directory already exists? I'm new to Hugo and could be missing out, but I'd expect you can have either, not both.
  3. Why panic, not error?
─(17:36)─(db)──(git:db_use_my_fork_of_maupassant_theme ✱ ◼)────────────────────────────────────────────────────────────[/home/db/projects/blog]─
hugo new content about.md
panic: [BUG] no Page found for "/home/db/projects/blog/content/about.md"

goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0xc000789080, {0xc00013b6b0, 0x27}, {0x40e5fc0, 0xc000394f00})
        /build/hugo/parts/hugo/build/create/content.go:273 +0x354
github.com/gohugoio/hugo/create.(*contentBuilder).buildFile(0xc000789080)
        /build/hugo/parts/hugo/build/create/content.go:242 +0x1ad
github.com/gohugoio/hugo/create.NewContent.func1()
        /build/hugo/parts/hugo/build/create/content.go:103 +0x15f
github.com/gohugoio/hugo/create.NewContent(0xc000a0ba40, {0x0, 0x0}, {0x7fff4b38fdda, 0x8}, 0x0)
        /build/hugo/parts/hugo/build/create/content.go:106 +0x5c6
github.com/gohugoio/hugo/commands.newNewCommand.func1({0x0?, 0x0?}, 0x0?, 0xc000a0a640, {0xc000a8c500, 0x0?, 0x0?})
        /build/hugo/parts/hugo/build/commands/new.go:60 +0x15f
github.com/gohugoio/hugo/commands.(*simpleCommand).Run(0x0?, {0x40dabe8?, 0x5600620?}, 0x0?, {0xc000a8c500?, 0xc0009a1a28?, 0x0?})
        /build/hugo/parts/hugo/build/commands/commandeer.go:618 +0x3c
github.com/bep/simplecobra.(*Commandeer).compile.func1(0xc00091f300?, {0xc000a8c500?, 0x4?, 0x2932317?})
        /build/hugo/parts/hugo/go/pkg/mod/github.com/bep/simplecobra@v0.4.0/simplecobra.go:113 +0x4c
github.com/spf13/cobra.(*Command).execute(0xc000a6ef08, {0xc000a8c4c0, 0x1, 0x1})
        /build/hugo/parts/hugo/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc0007e1208)
        /build/hugo/parts/hugo/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        /build/hugo/parts/hugo/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1048
github.com/bep/simplecobra.(*Exec).Execute(0xc00088edd0, {0x40dabe8?, 0x5600620?}, {0xc000132010?, 0x101?, 0xc0000a4688?})
        /build/hugo/parts/hugo/go/pkg/mod/github.com/bep/simplecobra@v0.4.0/simplecobra.go:155 +0xd4
github.com/gohugoio/hugo/commands.Execute({0xc000132010, 0x3, 0x3})
        /build/hugo/parts/hugo/build/commands/commandeer.go:68 +0x2f9
main.main()
        /build/hugo/parts/hugo/build/main.go:25 +0x56
─(17:36)─(db)──(git:db_use_my_fork_of_maupassant_theme ✱ ◼)────────────────────────────────────────────────────────────[/home/db/projects/blog]─
hugo version
hugo v0.127.0-74e0f3bd63c51f3c7a0f07a7c779eec9e922957e+extended linux/amd64 BuildDate=2024-06-05T10:27:59Z VendorInfo=snap:0.127.0
─(17:38)─(db)──(git:db_use_my_fork_of_maupassant_theme ✱ ◼)────────────────────────────────────────────────────────────[/home/db/projects/blog]─
ll ~/projects/blog/content
total 20K
drwxr-xr-x 2 db db 4.0K Jun 15 02:26 about
drwxr-xr-x 2 db db 4.0K Jun 15 02:26 archives
drwxr-xr-x 2 db db 4.0K Jun 15 02:26 post
drwxr-xr-x 2 db db 4.0K Jun 15 02:26 search
-rw-r--r-- 1 db db  102 Jun 15 17:36 about.md
─(17:39)─(db)──(git:db_use_my_fork_of_maupassant_theme ✱ ◼)────────────────────────────────────────────────────────────[/home/db/projects/blog]─
ll ~/projects/blog/content/about
total 4.0K
-rw-r--r-- 1 db db 582 Jun 15 02:26 index.md
─(17:42)─(db)──(git:db_use_my_fork_of_maupassant_theme ✱ ◼)────────────────────────────────────────────────────────────[/home/db/projects/blog]─
hugo new content tmp.md
Content "/home/db/projects/blog/content/tmp.md" created

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

$ hugo version
hugo v0.127.0-74e0f3bd63c51f3c7a0f07a7c779eec9e922957e+extended linux/amd64 BuildDate=2024-06-05T10:27:59Z VendorInfo=snap:0.127.0

Does this issue reproduce with the latest release?

I presume 0.127.0 is the latest.

@Plat251
Copy link

Plat251 commented Jun 24, 2024

I've also been having this issue, and in my situation I've managed to narrow it down to letter case, which I didn't pay much attention to before as I'm using a Windows machine.
Using the correct case give me expected results from hugo new content, and using any incorrect letter case gives me the exact same error output as Bryndin posted. This only happens when attempting to create a file in an existing directory or directories where the letter case in hugo new content argument is different from letter case in those directory names on the filesystem. Completely new directories and directory chains are created fine.

I can't say for sure if the issue is down to just letter case and whether it's OS-related (since Bryndin's posted output hints at Linux, so one would expect paths to be case-sensitive; unless, of course, the path is entirely handled by Hugo).

In any case, I did find the output printed frustratingly cryptic as a user, so if the letter case is the culprit, it's probably worthwhile to have a more informative error for this situation.

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants