Skip to content

feat(engine): add debug logging when lookup returns empty#32205

Merged
scottrigby merged 1 commit into
helm:mainfrom
ogulcanaydogan:feat/lookup-debug-logging
Jun 11, 2026
Merged

feat(engine): add debug logging when lookup returns empty#32205
scottrigby merged 1 commit into
helm:mainfrom
ogulcanaydogan:feat/lookup-debug-logging

Conversation

@ogulcanaydogan

Copy link
Copy Markdown
Contributor

When lookup cannot find the requested resource (apierrors.IsNotFound), add slog.Debug() calls so that users running helm template --debug can 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. The slog package and slog.String are already imported/used in this file (getDynamicClientOnKind), so no new imports are needed.

Files changed:

  • pkg/engine/lookup_func.go: add slog.Debug(...) in the apierrors.IsNotFound branch for single-object lookup and list lookup

Fixes #32101

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>
Copilot AI review requested due to automatic review settings June 11, 2026 09:40
@pull-request-size pull-request-size Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Debug logs when lookup gets IsNotFound for a single object fetch.
  • Emit slog.Debug logs when lookup gets IsNotFound for a list fetch.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/engine/lookup_func.go
Comment on lines +76 to +81
slog.Debug("lookup: resource not found",
slog.String("apiVersion", apiversion),
slog.String("kind", kind),
slog.String("namespace", namespace),
slog.String("name", name),
)
Comment thread pkg/engine/lookup_func.go
Comment on lines +94 to +98
slog.Debug("lookup: resource list not found",
slog.String("apiVersion", apiversion),
slog.String("kind", kind),
slog.String("namespace", namespace),
)
@promptless-for-oss

Copy link
Copy Markdown

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 lookup template function. When lookup returns empty because a resource wasn't found, users can now run with --debug to see which apiVersion, kind, namespace, and name were being looked up.

Review: Document lookup debug logging

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@TerryHowe TerryHowe added the Has One Approval This PR has one approval. It still needs a second approval to be merged. label Jun 11, 2026
@ogulcanaydogan

Copy link
Copy Markdown
Contributor Author

Thanks for the review @TerryHowe! Looks like a second review is needed — happy to address any additional feedback from other maintainers.

@scottrigby scottrigby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Thank you!

@scottrigby scottrigby added this to the 4.2.1 milestone Jun 11, 2026
@scottrigby
scottrigby merged commit 7058f84 into helm:main Jun 11, 2026
5 checks passed
@promptless-for-oss

Copy link
Copy Markdown

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 lookup template function. When lookup returns empty because a resource wasn't found, users can now run with --debug to see which apiVersion, kind, namespace, and name were being looked up.

Review: Document lookup debug logging

@scottrigby scottrigby added feature and removed Has One Approval This PR has one approval. It still needs a second approval to be merged. labels Jun 11, 2026
@scottrigby scottrigby modified the milestones: 4.2.1, 4.3.0 Jun 12, 2026
@scottrigby

Copy link
Copy Markdown
Member

This is actually a feature so should be in the next minor release.

@scottrigby scottrigby changed the title fix(engine): add debug logging when lookup returns empty feat(engine): add debug logging when lookup returns empty Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add some sort of warning (at least to debug level logging) if the lookup function returns nil

5 participants