diff --git a/storage/dvo_recommendations_storage.go b/storage/dvo_recommendations_storage.go index 52d0ae34..511caa4b 100644 --- a/storage/dvo_recommendations_storage.go +++ b/storage/dvo_recommendations_storage.go @@ -639,7 +639,10 @@ func (storage DVORecommendationsDBStorage) ReadWorkloadsForClusterAndNamespace( // filter report var reportData []types.DVOWorkload - json.Unmarshal([]byte(dvoReport.Report), &reportData) + err = json.Unmarshal([]byte(dvoReport.Report), &reportData) + if err != nil { + return dvoReport, err + } i := 0 // output index for _, x := range reportData { diff --git a/storage/dvo_recommendations_storage_test.go b/storage/dvo_recommendations_storage_test.go index f4fa61d3..d08442b6 100644 --- a/storage/dvo_recommendations_storage_test.go +++ b/storage/dvo_recommendations_storage_test.go @@ -829,8 +829,10 @@ func TestReadWorkloadsForClusterAndNamespace_HearbeatsFiltering(t *testing.T) { helpers.FailOnError(t, err) // write heartbeats - mockStorage.WriteHeartbeat("UID-0099", time.Now().UTC()) - mockStorage.WriteHeartbeat("UID-0100", time.Now().UTC().Add(-1*time.Hour).UTC()) + err = mockStorage.WriteHeartbeat("UID-0099", time.Now().UTC()) + helpers.FailOnError(t, err) + err = mockStorage.WriteHeartbeat("UID-0100", time.Now().UTC().Add(-1*time.Hour).UTC()) + helpers.FailOnError(t, err) report, err := mockStorage.ReadWorkloadsForClusterAndNamespace(testdata.OrgID, testdata.ClusterName, "NAMESPACE-UID-A") helpers.FailOnError(t, err)