From 84b40804b56873de65f7460ab86a39ac9147c79e Mon Sep 17 00:00:00 2001 From: Ethan Mosbaugh Date: Mon, 23 May 2022 19:43:43 +0000 Subject: [PATCH] filter nil analyzer results to prevent panic --- pkg/analyze/download.go | 7 +++++-- pkg/convert/supportbundle.go | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/analyze/download.go b/pkg/analyze/download.go index d39e0e31..7b6bf0c4 100644 --- a/pkg/analyze/download.go +++ b/pkg/analyze/download.go @@ -38,8 +38,11 @@ func AnalyzeLocal(localBundlePath string, analyzers []*troubleshootv1beta2.Analy continue } - if analyzeResult != nil { - analyzeResults = append(analyzeResults, analyzeResult...) + // Filter nil results to prevent panic + for _, r := range analyzeResult { + if r != nil { + analyzeResults = append(analyzeResults, r) + } } } diff --git a/pkg/convert/supportbundle.go b/pkg/convert/supportbundle.go index fbf71404..6be57792 100644 --- a/pkg/convert/supportbundle.go +++ b/pkg/convert/supportbundle.go @@ -69,6 +69,10 @@ func FromAnalyzerResult(input []*analyze.AnalyzeResult) []*Result { result := make([]*Result, 0) for _, i := range input { + // Continue on nil result to prevent panic + if i == nil { + continue + } name := reg.ReplaceAllString(strings.ToLower(i.Title), ".") r := &Result{ Meta: Meta{