criteo / biggraphite

Simple Scalable Time Series Database
Apache License 2.0
130 stars 35 forks source link

Fix list index out of range in _get_metrics when the metric doesn't exists #481

Closed adriengentil closed 6 years ago

adriengentil commented 6 years ago

This fix aims to prevent a "list index out of range" exception to be raised when the metric name doesn't exists in database:

Unhandled Error
        Traceback (most recent call last):
          File "/opt/graphite/pypy/site-packages/twisted/
            result = inContext.theWork()
          File "/opt/graphite/pypy/site-packages/twisted/
            inContext.theWork = lambda: context.call(ctx, 
          File "/opt/graphite/pypy/site-packages/twisted/
            return self.currentContext().callWithContext(
          File "/opt/graphite/pypy/site-packages/twisted/
            return func(*args,**kw)
        --- <exception caught here> ---
          File "/opt/graphite/pypy/site-packages/biggraphite/
            self._createOneMetric()
          File "/opt/graphite/pypy/site-packages/biggraphite/
            existing_metric = self.accessor.get_metric(
          File "/opt/graphite/pypy/site-packages/biggraphite/
            return next(iter(
          File "/opt/graphite/pypy/site-packages/biggraphite/
            if result[0] is not None:
          File "/opt/graphite/pypy/site-packages/cassandra/
            return self._current_rows[i]
        exceptions.IndexError: list index out of range
coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.003%) to 82.18% when pulling d990a9c0182e26d07ecb781c55af3ff5605a182c on adriengentil:fix-get-metrics into 36325f10f593e4ee0dbc1dbd2a6729e789dafe10 on criteo:master.