فهرست منبع

fix unsafe index access

AjayTripathy 6 سال پیش
والد
کامیت
ee7f1e1860
1فایلهای تغییر یافته به همراه3 افزوده شده و 0 حذف شده
  1. 3 0
      costmodel/cluster.go

+ 3 - 0
costmodel/cluster.go

@@ -90,6 +90,9 @@ func resultToTotal(qr interface{}) ([][]string, error) {
 	if !ok {
 		return nil, fmt.Errorf("Improperly formatted results from prometheus, result field is not a slice")
 	}
+	if len(results) == 0 {
+		return nil, fmt.Errorf("Not enough data available in the selected time range")
+	}
 	val, ok := results[0].(map[string]interface{})["value"]
 	totals := [][]string{}
 	if !ok {