Skip to content

Commit

Permalink
Merge pull request #12 from circonus-labs/CIRC-9041
Browse files Browse the repository at this point in the history
CIRC-9041: Fix null CAQL data value panics
  • Loading branch information
dhaifley authored Aug 26, 2022
2 parents 00339e3 + de96720 commit f15ddfc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build/
dist/

.DS_Store
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# v0.1.9

* fix: Correct a bug that lead to panics when CAQL data requested contained
null data values.

# v0.1.6

* fix: type assertion
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GOOS?=linux
OUT_DIR?=build
PACKAGE=github.com/circonus-labs/custom-metrics-circonus-adapter
PREFIX?=circonus
TAG = v0.1.0
TAG = v0.1.9
PKG := $(shell find pkg/* -type f)

.PHONY: build docker push test clean
Expand Down
9 changes: 9 additions & 0 deletions pkg/adapter/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ func (p *CirconusProvider) GetExternalMetric(ctx context.Context, namespace stri
}
count++
point := p.([]interface{})
if len(point) < 1 || point[0] == nil {
continue
}
resultEndTime := point[0].(float64)
if resultEndTime > finalTime {
finalTime = resultEndTime
Expand All @@ -259,7 +262,13 @@ func (p *CirconusProvider) GetExternalMetric(ctx context.Context, namespace stri
return nil, apierr.NewInternalError(fmt.Errorf("timeseries from Circonus has incorrect end time: %f", resultEndTime))
}
// point_data == []interface {}
if len(point) < 2 || point[1] == nil {
continue
}
pointData := point[1].([]interface{})
if len(pointData) < 1 || pointData[0] == nil {
continue
}
value := pointData[0].(float64)
finalValue += value
}
Expand Down

0 comments on commit f15ddfc

Please sign in to comment.