Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix panic when get with table output for resource w/o expected output (…
…#168) `flytectl get task/workflow/launchplan -o table` panics if resource has no expected output. We encountered `FormatVariableDescriptions at pkg/printer/printer.go:173` to panic when using the get commands on a resource without expected output. This happened with both explicit table output as well as default. Replicated on lastest master, workflow demo-1.no-output has no expected output: ``` $ go run ./main.go get launchplans -p demo-1 -d production --latest demo-1.no-output panic: assignment to entry in nil map goroutine 1 [running]: github.com/flyteorg/flytectl/pkg/printer.FormatVariableDescriptions(0x0) /workspace/flyteorg/flytectl/pkg/printer/printer.go:202 +0x307 github.com/flyteorg/flytectl/cmd/get.LaunchplanToTableProtoMessages({0xc000a30938, 0x1, 0x7ffeefbff977}) /workspace/flyteorg/flytectl/cmd/get/launch_plan.go:136 +0xee github.com/flyteorg/flytectl/cmd/get.getLaunchPlanFunc({0x2dfbf98, 0xc0000580b8}, {0xc0002fb8c0, 0x1, 0x11519b4}, {{0x2e55850, 0xc000a30120}, {0x2e472c0, 0xc0009a3110}, {0x2ddff60, ...}, ...}) /workspace/flyteorg/flytectl/cmd/get/launch_plan.go:158 +0x307 github.com/flyteorg/flytectl/cmd/core.generateCommandFunc.func1(0xc000481680, {0xc0002fb8c0, 0x1, 0x6}) /workspace/flyteorg/flytectl/cmd/core/cmd.go:69 +0x47d github.com/spf13/cobra.(*Command).execute(0xc000481680, {0xc0002fb860, 0x6, 0x6}) /workspace/go/pkg/mod/github.com/spf13/[email protected]/command.go:852 +0x60e github.com/spf13/cobra.(*Command).ExecuteC(0xc000480000) /workspace/go/pkg/mod/github.com/spf13/[email protected]/command.go:960 +0x3ad github.com/spf13/cobra.(*Command).Execute(...) /workspace/go/pkg/mod/github.com/spf13/[email protected]/command.go:897 github.com/flyteorg/flytectl/cmd.ExecuteCmd() /workspace/flyteorg/flytectl/cmd/root.go:135 +0x1e main.main() /workspace/flyteorg/flytectl/main.go:12 +0x1d exit status 2 ``` Simple fix: nil checks exists for container but not on the map itself prior to calling, and nil input causes the panic. Added nil check on map parameter prior to calling in all places found. Signed-off-by: Viktor Gerdin <[email protected]>
- Loading branch information