fix: safer error message in alerts (#27019)

(cherry picked from commit 686ce33ea5)
This commit is contained in:
Beto Dealmeida
2024-02-07 14:58:51 -05:00
committed by Michael S. Molina
parent 5a6109b2de
commit c974daa0c7

View File

@@ -150,7 +150,7 @@ class AlertCommand(BaseCommand):
rendered_sql, ALERT_SQL_LIMIT
)
_, username = get_executor(
executor, username = get_executor( # pylint: disable=unused-variable
executor_types=app.config["ALERT_REPORTS_EXECUTE_AS"],
model=self._report_schedule,
)
@@ -169,7 +169,12 @@ class AlertCommand(BaseCommand):
logger.warning("A timeout occurred while executing the alert query: %s", ex)
raise AlertQueryTimeout() from ex
except Exception as ex:
raise AlertQueryError(message=str(ex)) from ex
logger.exception("An error occurred when running alert query")
# The exception message here can reveal to much information to malicious
# users, so we raise a generic message.
raise AlertQueryError(
message=_("An error occurred when running alert query")
) from ex
def validate(self) -> None:
"""