diff --git a/pkg/chart/common/util/coalesce.go b/pkg/chart/common/util/coalesce.go index 999eeb208..49a9f2684 100644 --- a/pkg/chart/common/util/coalesce.go +++ b/pkg/chart/common/util/coalesce.go @@ -350,7 +350,11 @@ func coalesceTablesFullKey(printf printFn, dst, src map[string]any, prefix strin printf("warning: cannot overwrite table with non table for %s (%v)", fullkey, val) } } else if istable(dv) && val != nil { - printf("warning: destination for %s is a table. Ignoring non-table value (%v)", fullkey, val) + // Suppress warning when user supplies an empty map (nil-like); + // still warn for non-map values and non-empty maps. + if m, ok := val.(map[string]any); !ok || len(m) > 0 { + printf("warning: destination for %s is a table. Ignoring non-table value (%v)", fullkey, val) + } } } return dst diff --git a/pkg/chart/common/util/coalesce_test.go b/pkg/chart/common/util/coalesce_test.go index 33274920c..60549c3db 100644 --- a/pkg/chart/common/util/coalesce_test.go +++ b/pkg/chart/common/util/coalesce_test.go @@ -926,3 +926,34 @@ func TestCoalesceValuesSubchartNilCleanedWhenUserPartiallyOverrides(t *testing.T _, ok = keyMapping["password"] is.False(ok, "Expected keyMapping.password (nil from chart defaults) to be removed even when user partially overrides the map") } +func TestCoalesceValuesEmptyMapNoWarning(t *testing.T) { + warnings := make([]string, 0) + printf := func(format string, v ...any) { + t.Logf(format, v...) + warnings = append(warnings, fmt.Sprintf(format, v...)) + } + + // Chart default has a map key "data" + c := &chart.Chart{ + Metadata: &chart.Metadata{Name: "test"}, + Values: map[string]any{ + "data": map[string]any{ + "existing": "value", + }, + }, + } + + // User supplies an empty map for "data" – should NOT trigger a warning + vals := map[string]any{ + "data": map[string]any{}, + } + + _, err := coalesce(printf, c, vals, "", false) + if err != nil { + t.Fatal(err) + } + + if len(warnings) > 0 { + t.Errorf("expected no warnings, but got: %v", warnings) + } +}