feat(engine): add debug logging when lookup returns empty#32205
Conversation
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: helm#32101 Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds debug-level visibility into lookup behavior when Kubernetes resources (single object or list) are not found, to aid troubleshooting while preserving the existing “return empty map” template-friendly behavior.
Changes:
- Emit
slog.Debuglogs whenlookupgetsIsNotFoundfor a single object fetch. - Emit
slog.Debuglogs whenlookupgetsIsNotFoundfor a list fetch.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| slog.Debug("lookup: resource not found", | ||
| slog.String("apiVersion", apiversion), | ||
| slog.String("kind", kind), | ||
| slog.String("namespace", namespace), | ||
| slog.String("name", name), | ||
| ) |
| slog.Debug("lookup: resource list not found", | ||
| slog.String("apiVersion", apiversion), | ||
| slog.String("kind", kind), | ||
| slog.String("namespace", namespace), | ||
| ) |
|
Promptless prepared a documentation update related to this change. Triggered by PR #32205 Updated the debugging guide to document the new debug logging for the Review: Document lookup debug logging |
|
Thanks for the review @TerryHowe! Looks like a second review is needed — happy to address any additional feedback from other maintainers. |
scottrigby
left a comment
There was a problem hiding this comment.
This looks great. Thank you!
|
Promptless prepared a documentation update related to this change. Triggered by PR #32205 Updated the debugging guide to document the new debug logging for the Review: Document lookup debug logging |
|
This is actually a feature so should be in the next minor release. |
When
lookupcannot find the requested resource (apierrors.IsNotFound), addslog.Debug()calls so that users runninghelm template --debugcan see why lookup returned an empty map instead of silently swallowing the not-found result.The return value is unchanged — both branches still return
map[string]any{}, nil. Theslogpackage andslog.Stringare already imported/used in this file (getDynamicClientOnKind), so no new imports are needed.Files changed:
pkg/engine/lookup_func.go: addslog.Debug(...)in theapierrors.IsNotFoundbranch for single-object lookup and list lookupFixes #32101