Skip to content

Fix environment variable parsing for comma-separated values in CLI #20992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions components/gitpod-cli/cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,18 @@ func printVar(name string, value string, export bool) {
func parseArgs(args []string, pattern string) ([]*serverapi.UserEnvVarValue, error) {
vars := make([]*serverapi.UserEnvVarValue, len(args))
for i, arg := range args {
kv := strings.SplitN(arg, "=", 1)
if len(kv) != 1 || kv[0] == "" {
if arg == "" {
return nil, GpError{Err: xerrors.Errorf("empty string (correct format is key=value)"), OutCome: utils.Outcome_UserErr, ErrorCode: utils.UserErrorCode_InvalidArguments}
}

if !strings.Contains(kv[0], "=") {
if !strings.Contains(arg, "=") {
return nil, GpError{Err: xerrors.Errorf("%s has no equal character (correct format is %s=some_value)", arg, arg), OutCome: utils.Outcome_UserErr, ErrorCode: utils.UserErrorCode_InvalidArguments}
}

parts := strings.SplitN(kv[0], "=", 2)
parts := strings.SplitN(arg, "=", 2)
if len(parts) != 2 {
return nil, GpError{Err: xerrors.Errorf("invalid format: %s (correct format is key=value)", arg), OutCome: utils.Outcome_UserErr, ErrorCode: utils.UserErrorCode_InvalidArguments}
}

key := strings.TrimSpace(parts[0])
if key == "" {
Expand Down
Loading