From c5d5b922d7445540dcedb54fe33fd5a9cb9f4e3d Mon Sep 17 00:00:00 2001 From: Rayhan Hossain Date: Thu, 3 Dec 2026 08:54:46 -0800 Subject: [PATCH] fix: reject duplicate keys in chart source values Remove the repeated sidecarInjector.namespace key. Strictly decode both charts source values in the existing Go unit suite so duplicates fail before Helm rendering, even without Helm installed. Reproduced the exact duplicate-key failure before the fix; product race/vet and all 132 Helm tests pass afterward. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 33b3cb3c-1b25-4ffb-bff1-ebf0f3d04058 Signed-off-by: Rayhan Hossain --- operator/product-helm-chart/values.yaml | 1 - .../src/internal/product/chart_values_test.go | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 operator/src/internal/product/chart_values_test.go diff --git a/operator/product-helm-chart/values.yaml b/operator/product-helm-chart/values.yaml index 8544eada..882ac6bd 100644 --- a/operator/product-helm-chart/values.yaml +++ b/operator/product-helm-chart/values.yaml @@ -12,7 +12,6 @@ resources: sidecarInjector: enabled: false namespace: cnpg-system - namespace: cnpg-system image: repository: "" digest: "" diff --git a/operator/src/internal/product/chart_values_test.go b/operator/src/internal/product/chart_values_test.go new file mode 100644 index 00000000..739e5790 --- /dev/null +++ b/operator/src/internal/product/chart_values_test.go @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package product + +import ( + "os" + "path/filepath" + "testing" + + "sigs.k8s.io/yaml" +) + +func TestChartValuesAreStrictYAML(t *testing.T) { + for _, chart := range []string{"documentdb-helm-chart", "product-helm-chart"} { + t.Run(chart, func(t *testing.T) { + path := filepath.Join("../../../", chart, "values.yaml") + data, err := os.ReadFile(path) + if err != nil { + t.Fatal(err) + } + var values map[string]any + if err := yaml.UnmarshalStrict(data, &values); err != nil { + t.Fatalf("%s must not contain duplicate YAML keys: %v", path, err) + } + }) + } +}