diff --git a/kyaml/yaml/compatibility.go b/kyaml/yaml/compatibility.go index 41cf3e24a..904c8b15f 100644 --- a/kyaml/yaml/compatibility.go +++ b/kyaml/yaml/compatibility.go @@ -70,6 +70,9 @@ func IsYaml1_1NonString(node *Node) bool { } func IsValueNonString(value string) bool { + if value == "" { + return false + } if strings.Contains(value, "\n") { // multi-line strings will fail to unmarshal return false diff --git a/kyaml/yaml/compatibility_test.go b/kyaml/yaml/compatibility_test.go index 61a3b2e91..c2b9aa77f 100644 --- a/kyaml/yaml/compatibility_test.go +++ b/kyaml/yaml/compatibility_test.go @@ -23,6 +23,7 @@ func TestIsYaml1_1NonString(t *testing.T) { {val: "2", expected: true}, {val: "true", expected: true}, {val: "1.0\nhello", expected: false}, // multiline strings should always be false + {val: "", expected: false}, // empty string should be considered a string } for k := range valueToTagMap { @@ -111,7 +112,7 @@ var valueToTagMap = func() map[string]string { val := map[string]string{} // https://yaml.org/type/null.html - values := []string{"", "~", "null", "Null", "NULL"} + values := []string{"~", "null", "Null", "NULL"} for i := range values { val[values[i]] = "!!null" }