Vitor-Avila commented on code in PR #44992:
URL: https://github.com/apache/superset/pull/44992#discussion_r4202848505


##########
superset/commands/report/alert.py:
##########
@@ -214,37 +216,41 @@ def _execute_query(self) -> pd.DataFrame:
         :raises AlertQueryError: SQL query is not valid
         :raises AlertQueryTimeout: The SQL query received a celery soft timeout
         """
-        sql_template = jinja_context.get_template_processor(
-            database=self._report_schedule.database
-        )
-
         try:
-            rendered_sql = 
sql_template.process_template(self._report_schedule.sql)
-            self._validate_rendered_sql(rendered_sql)
-            limited_rendered_sql = 
self._report_schedule.database.apply_limit_to_sql(
-                rendered_sql, ALERT_SQL_LIMIT
-            )
-
-            if app.config["MUTATE_ALERT_QUERY"]:
-                limited_rendered_sql = (
-                    self._report_schedule.database.mutate_sql_based_on_config(
-                        limited_rendered_sql
-                    )
+            user = get_dynamic_executor(self._report_schedule, 
alert_query=True)
+            if user is not None:
+                username = user.username
+            else:
+                executor, username = get_executor(  # pylint: 
disable=unused-variable
+                    executors=app.config["ALERT_REPORTS_EXECUTORS"],
+                    model=self._report_schedule,
                 )
-
-            executor, username = get_executor(  # pylint: 
disable=unused-variable
-                executors=app.config["ALERT_REPORTS_EXECUTORS"],
-                model=self._report_schedule,
-            )
-            user = security_manager.find_user(username)
+                user = security_manager.find_user(username)
             # A deleted/disabled executor user makes find_user return None. 
Raise
             # the dedicated error so the handler below re-surfaces it instead 
of
             # masking it as an opaque AlertQueryError (or letting the missing 
user
             # surface as a NoneType error from the downstream auth flow).
-            if user is None:
+            if user is None or not user.is_active:
                 raise ReportScheduleExecutorNotFoundError(username)
 
             with override_user(user):

Review Comment:
   hmmmm this one is a bit tricky, @sadpandajoe. Added the `try/finally` in 
`core.py` directly, let me know your thoughts (could affect other parts. of the 
app).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to