From 7058f841af78112f81098e3f434f90d30c43b4fd Mon Sep 17 00:00:00 2001 From: Ogulcan Aydogan Date: Thu, 11 Jun 2026 22:31:18 +0100 Subject: [PATCH] fix(engine): add debug logging when lookup returns empty (#32205) 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