From 354507a4ea753878a6ebaff89cf4bee261117106 Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Thu, 16 Oct 2025 15:52:08 +0300 Subject: [PATCH] [lineage] Check for nil chart in HelmRelease Some HelmReleases use `chartRef` instead of `chart`. If the lineage webhook finds such a HelmRelease, a nil pointer dereference happens. This patch adds a nil check to guard against this. ```release-note [lineage] Add a nil check to guard against HelmReleases with a nil .spec.chart field when traversing the ownership tree. ``` Signed-off-by: Timofei Larkin --- internal/lineagecontrollerwebhook/config.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/lineagecontrollerwebhook/config.go b/internal/lineagecontrollerwebhook/config.go index c10c5a77..4ca45c13 100644 --- a/internal/lineagecontrollerwebhook/config.go +++ b/internal/lineagecontrollerwebhook/config.go @@ -38,6 +38,9 @@ func (l *LineageControllerWebhook) Map(hr *helmv2.HelmRelease) (string, string, if !ok { return "", "", "", fmt.Errorf("failed to load chart-app mapping from config") } + if hr.Spec.Chart == nil { + return "", "", "", fmt.Errorf("cannot map helm release %s/%s to dynamic app", hr.Namespace, hr.Name) + } s := hr.Spec.Chart.Spec val, ok := cfg.chartAppMap[chartRef{s.SourceRef.Name, s.Chart}] if !ok {