pipeline compiler: handle nil entrys in settings list (#1626)

close #1609
This commit is contained in:
6543 2023-03-17 08:54:53 +01:00 committed by GitHub
parent 1b43b0bf20
commit 9945e27c01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -111,6 +111,11 @@ func sanitizeParamValue(v interface{}, secrets map[string]string) (string, error
for i := 0; i < vv.Len(); i++ { for i := 0; i < vv.Len(); i++ {
v := vv.Index(i).Interface() v := vv.Index(i).Interface()
// if we handle a list with a nil entry we just return a empty list
if v == nil {
continue
}
// ensure each element is not complex // ensure each element is not complex
if isComplex(reflect.TypeOf(v).Kind()) { if isComplex(reflect.TypeOf(v).Kind()) {
containsComplex = true containsComplex = true

View file

@ -59,6 +59,11 @@ func TestParamsToEnv(t *testing.T) {
got := map[string]string{} got := map[string]string{}
assert.NoError(t, ParamsToEnv(from, got, secrets)) assert.NoError(t, ParamsToEnv(from, got, secrets))
assert.EqualValues(t, want, got, "Problem converting plugin parameters to environment variables") assert.EqualValues(t, want, got, "Problem converting plugin parameters to environment variables")
// handle edge cases (#1609)
got = map[string]string{}
assert.NoError(t, ParamsToEnv(map[string]interface{}{"a": []interface{}{"a", nil}}, got, nil))
assert.EqualValues(t, map[string]string{"PLUGIN_A": "a,"}, got)
} }
func TestSanitizeParamKey(t *testing.T) { func TestSanitizeParamKey(t *testing.T) {