diff --git a/internal/monocular/search.go b/internal/monocular/search.go index 29cc7f1a4..60b25a6e1 100644 --- a/internal/monocular/search.go +++ b/internal/monocular/search.go @@ -142,7 +142,9 @@ func (c *Client) SearchWithContext(ctx context.Context, term string) ([]SearchRe result := &searchResponse{} - json.NewDecoder(res.Body).Decode(result) + if err := json.NewDecoder(res.Body).Decode(result); err != nil { + return nil, fmt.Errorf("failed to decode search results from %s: %w", p.String(), err) + } return result.Data, nil } diff --git a/pkg/action/lint.go b/pkg/action/lint.go index 6156fe5c8..0c8c453ae 100644 --- a/pkg/action/lint.go +++ b/pkg/action/lint.go @@ -112,6 +112,9 @@ func lintChart(path string, vals map[string]any, namespace string, kubeVersion * if err != nil { return linter, fmt.Errorf("unable to read temporary output directory %s: %w", tempDir, err) } + if len(files) == 0 { + return linter, fmt.Errorf("temporary output directory %s is empty after extraction", tempDir) + } if !files[0].IsDir() { return linter, fmt.Errorf("unexpected file %s in temporary output directory %s", files[0].Name(), tempDir) } diff --git a/pkg/cmd/profiling.go b/pkg/cmd/profiling.go index 45e7b9342..1b5a4821d 100644 --- a/pkg/cmd/profiling.go +++ b/pkg/cmd/profiling.go @@ -74,12 +74,13 @@ func stopProfiling() error { f, err := os.Create(memProfilePath) if err != nil { errs = append(errs, err) - } - defer f.Close() + } else { + defer f.Close() - runtime.GC() // get up-to-date statistics - if err := pprof.WriteHeapProfile(f); err != nil { - errs = append(errs, err) + runtime.GC() // get up-to-date statistics + if err := pprof.WriteHeapProfile(f); err != nil { + errs = append(errs, err) + } } }