Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: safer error message in alerts #27019

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions superset/commands/report/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
rendered_sql, ALERT_SQL_LIMIT
)

_, username = get_executor(
executor, username = get_executor(

Check warning on line 153 in superset/commands/report/alert.py

View check run for this annotation

Codecov / codecov/patch

superset/commands/report/alert.py#L153

Added line #L153 was not covered by tests
executor_types=app.config["ALERT_REPORTS_EXECUTE_AS"],
model=self._report_schedule,
)
Expand All @@ -169,7 +169,12 @@
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")

Check warning on line 172 in superset/commands/report/alert.py

View check run for this annotation

Codecov / codecov/patch

superset/commands/report/alert.py#L172

Added line #L172 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand it's better to not share the system error message directly to the user, but I think it's ok for the system logs to have the actual error for the system operators. Even having the full stack trace on the system side would be a great thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mistercrunch I agree! logger.exception is different from logger.error in that will log the full stack trace together with the error message, so we're not losing any information here.

# The exception message here can reveal to much information to malicious
# users, so we raise a generic message.
raise AlertQueryError(

Check warning on line 175 in superset/commands/report/alert.py

View check run for this annotation

Codecov / codecov/patch

superset/commands/report/alert.py#L175

Added line #L175 was not covered by tests
message=_("An error occurred when running alert query")
) from ex

def validate(self) -> None:
"""
Expand Down
Loading