From d55d404cda59316d1afb41e7b38849d315d2b14c Mon Sep 17 00:00:00 2001 From: David Eliahu Date: Fri, 4 Jun 2021 14:48:39 -0700 Subject: [PATCH] Fix exception when creating Python client without default env set --- cli/cmd/env.go | 4 ---- cli/types/cliconfig/cli_config.go | 6 +++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/cmd/env.go b/cli/cmd/env.go index da85b9313e..7a736bf467 100644 --- a/cli/cmd/env.go +++ b/cli/cmd/env.go @@ -97,10 +97,6 @@ var _envListCmd = &cobra.Command{ } if _flagOutput == flags.JSONOutputType { - if len(cliConfig.Environments) == 0 { - fmt.Print("[]") - return - } bytes, err := libjson.Marshal(cliConfig.ConvertToUserFacingCLIConfig()) if err != nil { exit.Error(err) diff --git a/cli/types/cliconfig/cli_config.go b/cli/types/cliconfig/cli_config.go index 9f9bdbab71..2e1d4d8102 100644 --- a/cli/types/cliconfig/cli_config.go +++ b/cli/types/cliconfig/cli_config.go @@ -57,8 +57,12 @@ func (cliConfig *CLIConfig) Validate() error { } func (cliConfig *CLIConfig) ConvertToUserFacingCLIConfig() UserFacingCLIConfig { + envs := cliConfig.Environments + if envs == nil { + envs = []*Environment{} + } return UserFacingCLIConfig{ DefaultEnvironment: cliConfig.DefaultEnvironment, - Environments: cliConfig.Environments, + Environments: envs, } }