Skip to content

Commit 90d7e90

Browse files
authored
Fix exception when creating Python client without default env set (#2225)
1 parent 9cb33c2 commit 90d7e90

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cli/cmd/env.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ var _envListCmd = &cobra.Command{
9797
}
9898

9999
if _flagOutput == flags.JSONOutputType {
100-
if len(cliConfig.Environments) == 0 {
101-
fmt.Print("[]")
102-
return
103-
}
104100
bytes, err := libjson.Marshal(cliConfig.ConvertToUserFacingCLIConfig())
105101
if err != nil {
106102
exit.Error(err)

cli/types/cliconfig/cli_config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ func (cliConfig *CLIConfig) Validate() error {
5757
}
5858

5959
func (cliConfig *CLIConfig) ConvertToUserFacingCLIConfig() UserFacingCLIConfig {
60+
envs := cliConfig.Environments
61+
if envs == nil {
62+
envs = []*Environment{}
63+
}
6064
return UserFacingCLIConfig{
6165
DefaultEnvironment: cliConfig.DefaultEnvironment,
62-
Environments: cliConfig.Environments,
66+
Environments: envs,
6367
}
6468
}

0 commit comments

Comments
 (0)