fix: return empty array if no option multi-selected (#19224)

Related: https://github.com/coder/coder/issues/19145
This commit is contained in:
Marcin Tojek
2025-08-07 11:37:58 +00:00
committed by GitHub
parent 91780db1fe
commit 2851d9f3ea
2 changed files with 16 additions and 1 deletions
+5 -1
View File
@@ -349,7 +349,11 @@ func RichMultiSelect(inv *serpent.Invocation, richOptions RichMultiSelectOptions
}
// Check selected option, convert descriptions (line) to values
var results []string
//
// The function must return an initialized empty array, since it is later marshaled
// into JSON. Otherwise, `var results []string` would be marshaled to "null".
// See: https://github.com/golang/go/issues/27589
results := []string{}
for _, sel := range selected {
custom := true
for i, option := range richOptions.Options {