From 9945e27c0189f6229d546703ac7f2b340a366cea Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 17 Mar 2023 08:54:53 +0100 Subject: [PATCH] pipeline compiler: handle nil entrys in settings list (#1626) close #1609 --- pipeline/frontend/yaml/compiler/settings/params.go | 5 +++++ pipeline/frontend/yaml/compiler/settings/params_test.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pipeline/frontend/yaml/compiler/settings/params.go b/pipeline/frontend/yaml/compiler/settings/params.go index 9bbeb5d49..a021d3daa 100644 --- a/pipeline/frontend/yaml/compiler/settings/params.go +++ b/pipeline/frontend/yaml/compiler/settings/params.go @@ -111,6 +111,11 @@ func sanitizeParamValue(v interface{}, secrets map[string]string) (string, error for i := 0; i < vv.Len(); i++ { 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 if isComplex(reflect.TypeOf(v).Kind()) { containsComplex = true diff --git a/pipeline/frontend/yaml/compiler/settings/params_test.go b/pipeline/frontend/yaml/compiler/settings/params_test.go index 22ab60aa5..37ec227ae 100644 --- a/pipeline/frontend/yaml/compiler/settings/params_test.go +++ b/pipeline/frontend/yaml/compiler/settings/params_test.go @@ -59,6 +59,11 @@ func TestParamsToEnv(t *testing.T) { got := map[string]string{} assert.NoError(t, ParamsToEnv(from, got, secrets)) 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) {