getredash/redash

When evaluating alert, AttributeError: 'NoneType' object has no attribute 'data' in alerts.py

Opened this issue · 1 comments

Issue Summary

On our self-hosted Redash instance (2 replicas mode), we've set up certain alert to evaluate every 12 hours, however it was showing to us as "Unknown" status constantly. Even upon manual trigger of Evaluation, status just wouldn't change.

After manual trigger, in Pod logs I've discovered that on manual evaluate a Python trace appeared (attached below).

It also looks like that the values we want alert to act on are properly fetched, as there is no "NaN", null, undefined, or any else.

image

Example error trace from the moment I hit evaluate:

[2024-10-18 13:28:03,043][PID:1231][ERROR][redash.app] Exception on /default/api/alerts/496/eval [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/flask_login/utils.py", line 277, in decorated_view
return current_app.ensure_sync(func)(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/flask/views.py", line 109, in view
return current_app.ensure_sync(self.dispatch_request)(**kwargs)
File "/app/redash/handlers/base.py", line 31, in dispatch_request
return super(BaseResource, self).dispatch_request(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
resp = meth(*args, **kwargs)
File "/app/redash/handlers/alerts.py", line 55, in post
new_state = alert.evaluate()
File "/app/redash/models/__init__.py", line 962, in evaluate
data = self.query_rel.latest_query_data.data
AttributeError: 'NoneType' object has no attribute 'data'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/usr/local/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper
resp = resource(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/flask_login/utils.py", line 279, in decorated_view
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/flask/views.py", line 109, in view
return current_app.ensure_sync(self.dispatch_request)(**kwargs)
File "/app/redash/handlers/base.py", line 31, in dispatch_request
return super(BaseResource, self).dispatch_request(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
resp = meth(*args, **kwargs)
File "/app/redash/handlers/alerts.py", line 55, in post
new_state = alert.evaluate()
File "/app/redash/models/__init__.py", line 962, in evaluate
data = self.query_rel.latest_query_data.data
AttributeError: 'NoneType' object has no attribute 'data'

Steps to Reproduce

  1. Set up alert, set to evaluate every x hours; either wait or trigger evaluation manually
  2. See trace in logs

Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

Technical details:

  • Redash Version: 24.10.0-dev from redash/preview
  • Browser/OS: Safari Version 17.3.1 (19617.2.4.11.12) ; Mac OS 14.3.1 (23D60)
  • How did you install Redash: self-hosted from self-managed Helm chart

If there is any other info I could provide, I will gladly do.

@knuurr The fix in #7208 is in the 24.11.0-dev snapshot. Let us know if that solves the problem