From 9cbf94fb60b79fd0c1424e69da0a3267190d5f63 Mon Sep 17 00:00:00 2001 From: Arunesh Dwivedi Date: Thu, 4 Jun 2026 10:01:11 +0000 Subject: [PATCH] fix: prevent nil pointer dereference in installCRDs when res is empty When KubeClient.Build() returns an empty resource slice and the CRD already exists, accessing res[0].Name causes a panic. Add a length check before accessing res[0]. Fixes #31552 Signed-off-by: Arunesh Dwivedi --- pkg/action/install.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/action/install.go b/pkg/action/install.go index 8ae84a699..98cc44e23 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -172,6 +172,10 @@ func (i *Install) installCRDs(crds []chart.CRD) error { if _, err := i.cfg.KubeClient.Create(res); err != nil { // If the error is CRD already exists, continue. if apierrors.IsAlreadyExists(err) { + if len(res) == 0 { + i.cfg.Log("CRD %s is already present. Skipping.", obj.Name) + continue + } crdName := res[0].Name i.cfg.Log("CRD %s is already present. Skipping.", crdName) continue