From d7778ff63606fa213663185b95851d0b05ec8236 Mon Sep 17 00:00:00 2001 From: Ogulcan Aydogan Date: Thu, 11 Jun 2026 10:39:56 +0100 Subject: [PATCH] fix(engine): add debug logging when lookup returns empty When lookup cannot find the requested resource (apierrors.IsNotFound), add slog.Debug() calls with structured fields (apiVersion, kind, namespace, name) so that users running helm template --debug can see why lookup returned an empty map instead of silently swallowing the not-found result. Fixes: https://github.com/helm/helm/issues/32101 Signed-off-by: Ogulcan Aydogan --- pkg/engine/lookup_func.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 52b6ffdaf..c5c441c14 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -73,6 +73,12 @@ func newLookupFunction(clientProvider ClientProvider) lookupFunc { if apierrors.IsNotFound(err) { // Just return an empty interface when the object was not found. // That way, users can use `if not (lookup ...)` in their templates. + slog.Debug("lookup: resource not found", + slog.String("apiVersion", apiversion), + slog.String("kind", kind), + slog.String("namespace", namespace), + slog.String("name", name), + ) return map[string]any{}, nil } return map[string]any{}, err @@ -85,6 +91,11 @@ func newLookupFunction(clientProvider ClientProvider) lookupFunc { if apierrors.IsNotFound(err) { // Just return an empty interface when the object was not found. // That way, users can use `if not (lookup ...)` in their templates. + slog.Debug("lookup: resource list not found", + slog.String("apiVersion", apiversion), + slog.String("kind", kind), + slog.String("namespace", namespace), + ) return map[string]any{}, nil } return map[string]any{}, err