chanzuckerberg / happy

Happy Path Deployment Tool

Home Page:https://chanzuckerberg.github.io/happy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Panic Validating docker-compose

jakeyheath opened this issue · comments

MustParse panics if the semantic version isn't formatted correctly (https://github.com/chanzuckerberg/happy/blame/172d22d7303b7ea790ac54a977755773e05871d3/pkg/util/preconditions.go#L33). I doubt this is the behavior you would want here. When I was testing out CLI usage, I ran happy build and got this:

% happy build
panic: Invalid Semantic Version

goroutine 1 [running]:
github.com/Masterminds/semver/v3.MustParse(...)
        github.com/Masterminds/semver/v3@v3.1.1/version.go:214
github.com/chanzuckerberg/happy/pkg/util.ValidateEnvironment({0x2326448, 0xc0000a8000})
        github.com/chanzuckerberg/happy/pkg/util/preconditions.go:33 +0x706
github.com/chanzuckerberg/happy/cmd.glob..func5(0x2dc3ea0, {0x2020dca, 0x0, 0x0})
        github.com/chanzuckerberg/happy/cmd/root.go:39 +0x6c
github.com/spf13/cobra.(*Command).execute(0x2dc3ea0, {0x2dfd0e8, 0x0, 0x0})
        github.com/spf13/cobra@v1.3.0/command.go:835 +0x52f
github.com/spf13/cobra.(*Command).ExecuteC(0x2dc43a0)
        github.com/spf13/cobra@v1.3.0/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.3.0/command.go:902
github.com/chanzuckerberg/happy/cmd.Execute(...)
        github.com/chanzuckerberg/happy/cmd/root.go:46
main.main()
        github.com/chanzuckerberg/happy/main.go:17 +0x68

I understand that I don't have a file set up properly, but I think using an API that allows you to return an error with a meaningful message would be more helpful than a panic. This also seems to happen with commands like checking the happy version:

% happy version
panic: Invalid Semantic Version

goroutine 1 [running]:
github.com/Masterminds/semver/v3.MustParse(...)
        github.com/Masterminds/semver/v3@v3.1.1/version.go:214
github.com/chanzuckerberg/happy/pkg/util.ValidateEnvironment({0x2326448, 0xc000034098})
        github.com/chanzuckerberg/happy/pkg/util/preconditions.go:33 +0x706
github.com/chanzuckerberg/happy/cmd.glob..func5(0x2dc34a0, {0x2020dca, 0x0, 0x0})
        github.com/chanzuckerberg/happy/cmd/root.go:39 +0x6c
github.com/spf13/cobra.(*Command).execute(0x2dc34a0, {0x2dfd0e8, 0x0, 0x0})
        github.com/spf13/cobra@v1.3.0/command.go:835 +0x52f
github.com/spf13/cobra.(*Command).ExecuteC(0x2dc43a0)
        github.com/spf13/cobra@v1.3.0/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.3.0/command.go:902
github.com/chanzuckerberg/happy/cmd.Execute(...)
        github.com/chanzuckerberg/happy/cmd/root.go:46
main.main()
        github.com/chanzuckerberg/happy/main.go:17 +0x68

Closed by #162