From bf2c8c4af07251393df4ba7e65644b2f8ee6ebab Mon Sep 17 00:00:00 2001 From: Kartik Suryavanshi <158498247+KartikSuryavanshi@users.noreply.github.com> Date: Wed, 15 Jul 2026 22:03:27 +0530 Subject: [PATCH] fix: preserve original symlink FileInfo on Lstat failure Save the original symlink info before os.Lstat(resolved) overwrites it, so walkFn receives the symlink's FileInfo (not nil) on error. This allows .helmignore pattern matching to work correctly for broken symlinks. Signed-off-by: Kartik Suryavanshi Signed-off-by: Kartik Suryavanshi <158498247+KartikSuryavanshi@users.noreply.github.com> --- internal/sympath/walk.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/sympath/walk.go b/internal/sympath/walk.go index caacec306..41b6cd6f0 100644 --- a/internal/sympath/walk.go +++ b/internal/sympath/walk.go @@ -73,10 +73,11 @@ func symwalk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error { } // This log message is to highlight a symlink that is being used within a chart, symlinks can be used for nefarious reasons. slog.Info("found symbolic link in path. Contents of linked file included and used", "path", path, "resolved", resolved) + originalInfo := info if info, err = os.Lstat(resolved); err != nil { // Route through walkFn with the original symlink info so callers // can decide whether to skip it based on .helmignore rules. - return walkFn(path, info, err) + return walkFn(path, originalInfo, err) } if err := symwalk(path, info, walkFn); err != nil && err != filepath.SkipDir { return err