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 <ogulcanaydogan@hotmail.com>
pull/32208/head
Ogulcan Aydogan 4 weeks ago committed by GitHub
parent 5c3cb20e76
commit 7058f841af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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

Loading…
Cancel
Save