From 4d6ffd213b7f3180c7bae857fea0ef7377578db9 Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Tue, 10 Oct 2023 10:35:44 -0600 Subject: [PATCH] Added checks for `connectGofish` to prevent panics --- internal/collect.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/collect.go b/internal/collect.go index 0f43d75..7cead57 100644 --- a/internal/collect.go +++ b/internal/collect.go @@ -632,11 +632,16 @@ func QueryProcessors(q *QueryParams) ([]byte, error) { func connectGofish(q *QueryParams) (*gofish.APIClient, error) { config := makeGofishConfig(q) c, err := gofish.Connect(config) - c.Service.ProtocolFeaturesSupported = gofish.ProtocolFeaturesSupported{ - ExpandQuery: gofish.Expand{ - ExpandAll: true, - Links: true, - }, + if err != nil { + return nil, fmt.Errorf("could not connect to redfish endpoint: %v", err) + } + if c != nil { + c.Service.ProtocolFeaturesSupported = gofish.ProtocolFeaturesSupported{ + ExpandQuery: gofish.Expand{ + ExpandAll: true, + Links: true, + }, + } } return c, err }