From 144d8211a3671c9c680d07212988ee2eb9100fb5 Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Wed, 27 Dec 2023 08:14:16 +1100 Subject: [PATCH] fix: dont panic in processing, log the issue and move on --- internal/handler/insightsFactsParserFilter.go | 2 +- internal/handler/insightsParserFilter.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/handler/insightsFactsParserFilter.go b/internal/handler/insightsFactsParserFilter.go index 885e07e..667569c 100644 --- a/internal/handler/insightsFactsParserFilter.go +++ b/internal/handler/insightsFactsParserFilter.go @@ -53,7 +53,7 @@ func processFactsFromJSON(logger *slog.Logger, facts []byte, source string) []La err := json.Unmarshal(facts, &factsPayload) if err != nil { logger.Error(err.Error()) - panic("Can't unmarshal facts") + return nil } if len(factsPayload.Facts) == 0 { diff --git a/internal/handler/insightsParserFilter.go b/internal/handler/insightsParserFilter.go index 70950f9..32689d9 100644 --- a/internal/handler/insightsParserFilter.go +++ b/internal/handler/insightsParserFilter.go @@ -54,7 +54,8 @@ func processSbomInsightsData(h *Messaging, insights InsightsData, v string, apiC decoder := cdx.NewBOMDecoder(bytes.NewReader(b), cdx.BOMFileFormatJSON) if err = decoder.Decode(bom); err != nil { - panic(err) + logger.Error(err.Error()) + return nil, "", mErr } }