Skip to content

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

@deining

Description

@deining

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions