From 1588736b4e590e77aaee708d5b6fc4ce8ce9a9fa Mon Sep 17 00:00:00 2001 From: alingse Date: Tue, 22 Apr 2025 06:26:57 +0800 Subject: [PATCH] Fix: call errors.Wrap with a nil value error err (#6739) Signed-off-by: alingse --- pkg/addon/addon.go | 4 ++-- pkg/utils/file.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/addon/addon.go b/pkg/addon/addon.go index 36ea10d88..ebfc28210 100644 --- a/pkg/addon/addon.go +++ b/pkg/addon/addon.go @@ -1626,8 +1626,8 @@ func (h *Installer) renderNotes(addon *InstallPackage) (string, error) { } notesFile := contextFile + "\n" + addon.Notes.Data val := cuecontext.New().CompileString(notesFile) - if val.Err() != nil { - return "", errors.Wrap(err, "build values for NOTES.cue") + if valErr := val.Err(); valErr != nil { + return "", errors.Wrap(valErr, "build values for NOTES.cue") } notes := val.LookupPath(cue.ParsePath(KeyWordNotes)) if !notes.Exists() { diff --git a/pkg/utils/file.go b/pkg/utils/file.go index 8e8e16def..00b3ff1ec 100644 --- a/pkg/utils/file.go +++ b/pkg/utils/file.go @@ -80,7 +80,7 @@ func LoadDataFromPath(ctx context.Context, path string, pathFilter func(string) } bs, e := os.ReadFile(filepath.Clean(path)) if e != nil { - return nil, fmt.Errorf("failed to read file %s: %w", path, err) + return nil, fmt.Errorf("failed to read file %s: %w", path, e) } return []FileData{{Path: path, Data: bs}}, nil }