coinbase/mesh-cli

Running check:construction without flags causes nil pointer dereference

t-hale opened this issue · 0 comments

Describe the bug
When running the check:construction command with no arguments, the CLI panics on a nil pointer dereference in https://github.com/coinbase/rosetta-cli/blob/master/pkg/results/construction_results.go#L316

To Reproduce

❯ go run main.go check:construction

Error: construction configuration is missing
github.com/coinbase/rosetta-cli/pkg/results.ExitConstruction
	/Users/tyler/Documents/github/rosetta-cli/pkg/results/construction_results.go:305
github.com/coinbase/rosetta-cli/cmd.runCheckConstructionCmd
	/Users/tyler/Documents/github/rosetta-cli/cmd/check_construction.go:58
github.com/spf13/cobra.(*Command).execute
	/Users/tyler/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:856
github.com/spf13/cobra.(*Command).ExecuteC
	/Users/tyler/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:974
github.com/spf13/cobra.(*Command).Execute
	/Users/tyler/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:902
github.com/coinbase/rosetta-cli/cmd.Execute
	/Users/tyler/Documents/github/rosetta-cli/cmd/root.go:170
main.main
	/Users/tyler/Documents/github/rosetta-cli/main.go:26
runtime.main
	/usr/local/Cellar/go/1.17.5/libexec/src/runtime/proc.go:255
runtime.goexit
	/usr/local/Cellar/go/1.17.5/libexec/src/runtime/asm_amd64.s:1581

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x98 pc=0x45442db]

goroutine 1 [running]:
github.com/coinbase/rosetta-cli/pkg/results.ExitConstruction(0xc0001d9080, 0xb, 0x6, {0x4a3ae80, 0xc00010f800})
	/Users/tyler/Documents/github/rosetta-cli/pkg/results/construction_results.go:317 +0x11b
github.com/coinbase/rosetta-cli/cmd.runCheckConstructionCmd(0x4e7cd20, {0x4832e5b, 0x0, 0x0})
	/Users/tyler/Documents/github/rosetta-cli/cmd/check_construction.go:58 +0xb5b
github.com/spf13/cobra.(*Command).execute(0x4e7cd20, {0x4ebc6b0, 0x0, 0x0})
	/Users/tyler/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0x4e7caa0)
	/Users/tyler/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/tyler/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:902
github.com/coinbase/rosetta-cli/cmd.Execute()
	/Users/tyler/Documents/github/rosetta-cli/cmd/root.go:170 +0x4c
main.main()
	/Users/tyler/Documents/github/rosetta-cli/main.go:26 +0x19
exit status 2

Expected behavior
The command should print the stack trace if the configuration is missing (and they haven't disabled stack traces in their rosetta config), print the usage message, and exit with a nonzero result value

Additional context
N/A