diff --git a/webapp/graphite/render/functions.py b/webapp/graphite/render/functions.py index 8630feb8f..329149ff9 100644 --- a/webapp/graphite/render/functions.py +++ b/webapp/graphite/render/functions.py @@ -2427,6 +2427,9 @@ def nonNegativeDerivative(requestContext, seriesList, maxValue=None, minValue=No def _nonNegativeDelta(val, prev, maxValue, minValue): + if val is None: + return None, None + # ignore values larger than maxValue if maxValue is not None and val > maxValue: return None, None @@ -2434,7 +2437,7 @@ def _nonNegativeDelta(val, prev, maxValue, minValue): return None, None # first reading - if None in (prev, val): + if prev is None: return None, val # counter increased, use the difference diff --git a/webapp/tests/test_functions.py b/webapp/tests/test_functions.py index cf3fce468..56f7dd959 100644 --- a/webapp/tests/test_functions.py +++ b/webapp/tests/test_functions.py @@ -1798,6 +1798,10 @@ def test_perSecond_nones(self): result = functions.scaleToSeconds({}, functions.nonNegativeDerivative({}, seriesList), 1) self.assertEqual(list(expected[0]), list(result[0])) + # None values should not raise TypeError when maxValue is set + result = functions.perSecond({}, seriesList, maxValue=1000) + self.assertEqual(list(expected[0]), list(result[0])) + def test_perSecond_max(self): seriesList = self._gen_series_list_with_data(key='test',start=0,end=600,step=60,data=[0, 120, 240, 480, 960, 900, 120, 240, 119, 479]) expected = [TimeSeries('perSecond(test)', 0, 600, 60, [None, 2, 2, 4, None, None, None, 2, 6, 6])]