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 deploy: runtime error with empty section [[deployment.matchers]] #9220

Closed
deining opened this issue Nov 30, 2021 · 5 comments · Fixed by #9221
Closed

hugo deploy: runtime error with empty section [[deployment.matchers]] #9220

deining opened this issue Nov 30, 2021 · 5 comments · Fixed by #9221
Labels

Comments

@deining
Copy link
Contributor

deining commented Nov 30, 2021

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

$ hugo version
hugo v0.89.4-AB01BA6E+extended windows/amd64 BuildDate=2021-11-17T08:24:09Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes.

How to reproduce:

Take an arbitrary hugo site and add the section below to the site's config.toml:

[deployment] 
[[deployment.targets]]
name = "aws"
URL = "s3://www.your-domain.tld"
cloudFrontDistributionID = "E9RZ8T1EXAMPLEID"

[[deployment.matchers]]
#pattern = "^.+\\.(html|xml|json)$"
#gzip = true

If you now run hugo deploy, you end up with a runtime error:

hugo deploy
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x8 pc=0x253e54b]

goroutine 1 [running]:
github.com/gohugoio/hugo/deploy.decodeConfig({0x31df7b8, 0xc0001fda40})
        /root/project/hugo/deploy/deployConfig.go:133 +0x26b
github.com/gohugoio/hugo/deploy.New({0x31df7b8, 0xc0001fda40}, {0x31dd6a0, 0xc00053be48})
        /root/project/hugo/deploy/deploy.go:80 +0xc8
github.com/gohugoio/hugo/commands.(*commandsBuilder).newDeployCmd.func1(0xc000457900, {0x2c6a545, 0x2, 0x2})
        /root/project/hugo/commands/deploy.go:67 +0xdc
github.com/spf13/cobra.(*Command).execute(0xc000457900, {0xc00055f5e0, 0x2, 0x2})
        /go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc00040a000)
        /go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/gohugoio/hugo/commands.Execute({0xc000050090, 0x3, 0x3})
        /root/project/hugo/commands/hugo.go:92 +0xb4
main.main()
        /root/project/hugo/main.go:23 +0x58

As soon as you uncomment the last two lines of the added section, everything works fine again.

Certainly a low priority issue, but I reckon having an empty [[deployment.matchers]] section could/should be handled more gracefully and hugo shouldn't choke on this.

@deining
Copy link
Contributor Author

deining commented Dec 3, 2021

The merged fix works and is certainly an improvement, thanks for addressing this so quickly.
However, I realized that the whole deployment process is canceled once an empty deployment matcher is encountered. i wouldn't consider an empty deployment matcher critical, so issuing a warning and continuing with deployment would be a more appropriate reaction for me here. Thoughts?

@bep bep reopened this Dec 3, 2021
@bep bep closed this as completed Dec 3, 2021
@bep
Copy link
Member

bep commented Dec 3, 2021

so issuing a warning and continuing with deployment would be a more appropriate reaction for me here. Thoughts?

I agree.

/cc @jmooring

@bep bep reopened this Dec 3, 2021
@jmooring
Copy link
Member

jmooring commented Dec 4, 2021

Need guidance. Hugo neither warns nor errors with this config:

[[menu.main]]
[[menu.main]]
[[menu.main]]

To be consistent, it seems like this shouldn't produce warnings or errors either:

[[deployment]]
[[deployment.targets]]
[[deployment.targets]]
[[deployment.matchers]]
[[deployment.matchers]]

Please advise.

@bep
Copy link
Member

bep commented Dec 4, 2021

I have changed my mind. We throw error on these situations -- people need to fix their config.

@bep bep closed this as completed Dec 4, 2021
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants