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

chore: Add USER_CLIENT_ERRORS to stop logging exceptions that are user driven #21818

Merged
merged 1 commit into from
Oct 15, 2022
Merged
Changes from all commits
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
13 changes: 10 additions & 3 deletions superset/sqllab/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from __future__ import annotations

import logging
from typing import Any, Dict, Optional, TYPE_CHECKING
from typing import Any, Dict, Optional, Set, TYPE_CHECKING

from flask_babel import gettext as __

Expand Down Expand Up @@ -53,6 +53,13 @@

CommandResult = Dict[str, Any]

# Define set of users client errors these definitions won't
# be logged as exception vs. warning
USER_CLIENT_ERRORS: Set[SupersetErrorType] = {
SupersetErrorType.SYNTAX_ERROR,
SupersetErrorType.COLUMN_DOES_NOT_EXIST_ERROR,
}


class ExecuteSqlCommand(BaseCommand):
_execution_context: SqlJsonExecutionContext
Expand Down Expand Up @@ -116,11 +123,11 @@ def run( # pylint: disable=too-many-statements,useless-suppression
"payload": self._execution_context_convertor.serialize_payload(),
}
except SupersetErrorsException as ex:
if all(ex.error_type == SupersetErrorType.SYNTAX_ERROR for ex in ex.errors):
if all(ex.error_type in USER_CLIENT_ERRORS for ex in ex.errors):
raise SupersetSyntaxErrorException(ex.errors) from ex
raise ex
except SupersetException as ex:
if ex.error_type == SupersetErrorType.SYNTAX_ERROR:
if ex.error_type in USER_CLIENT_ERRORS:
raise SupersetSyntaxErrorException(
[
SupersetError(
Expand Down