redash
redash copied to clipboard
TypeError: float() argument must be a string or a number, not 'NoneType' in `redash.models.next_state`
Issue Summary
Using a self-hosted redash instance running in docker-compose with image redash/redash:10.0.0.b50363. The instance was upgraded from redash 8, with celery replaced with rq according to the release notes.
Every once in a while redash emits this traceback to sentry/logs:
TypeError: float() argument must be a string or a number, not 'NoneType'
File "rq/worker.py", line 934, in perform_job
rv = job.perform()
File "rq/job.py", line 686, in perform
self._result = self._execute()
File "rq/job.py", line 692, in _execute
return self.func(*self.args, **self.kwargs)
File "redash/tasks/alerts.py", line 42, in check_alerts_for_query
new_state = alert.evaluate()
File "redash/models/__init__.py", line 1012, in evaluate
new_state = next_state(op, value, threshold)
File "redash/models/__init__.py", line 945, in next_state
value = float(value)
Some of the values Sentry catches are:
-
RedashQueue('default') -
Alert(id=25, name='<redacted>', query_id=606, user_id=3, state='ok', last_triggered_at=datetime.datetime(2021, 10, 8, 8, 34, 47, 531995, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=180, name=None)), rearm=10800) -
Query(id=606, name='<redacted>', query_hash='c53ed27f20858a88b18604ba5e803fdf', version=1, user_id=3, org_id=1, data_source_id=1, query_hash='c53ed27f20858a88b18604ba5e803fdf', last_modified_by_id=3, is_archived=False, is_draft=False, schedule={'interval': 1800, 'until': None, 'day_of_week': None, 'time': None}, schedule_failures=0) -
datais
{columns: [{friendly_name: 'col1', name: 'col1', type: 'integer'}, {friendly_name: 'col2', name: 'col2', type: 'integer'}], rows: [{col1: None, col2: None}]}
and the alert is on col1 > 0. It looks like redash 8 handled col1 = None (in which case, not triggering the alert), but redash 10 doesn't.
Steps to Reproduce
I admittedly didn't try it, but it would probably be:
- Create a query
col1, col2which returnsNULL, NULL. - Create alert on
col1 > 0. - Alert check should cause the traceback.
Technical details:
- Redash Version: 10.0.0.b50363
- Browser/OS: Firefox/Linux
- How did you install Redash: docker-compose
Try and check if it is a spelling problem, maybe you left a space where you were not supposed to. I just solved this issue in my OOP project
Sorry to only just get to this. Yep this is a real bug and your reproduction steps are correct. I've self-assigned
[edit] What is the desired behaviour in this case?
i have the same issue

What is the desired behaviour in this case?
ideally, still send an alert but mention that the value is none?