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: Avoid 500 if end users write bad SQL #26638

Merged
merged 3 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion superset/db_engine_specs/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ class SupersetDBAPIOperationalError(SupersetDBAPIError):


class SupersetDBAPIProgrammingError(SupersetDBAPIError):
pass
status = 400
11 changes: 10 additions & 1 deletion superset/db_engine_specs/trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
from superset.constants import QUERY_CANCEL_KEY, QUERY_EARLY_CANCEL_KEY, USER_AGENT
from superset.databases.utils import make_url_safe
from superset.db_engine_specs.base import BaseEngineSpec
from superset.db_engine_specs.exceptions import SupersetDBAPIConnectionError
from superset.db_engine_specs.exceptions import (
SupersetDBAPIConnectionError,
SupersetDBAPIDatabaseError,
SupersetDBAPIOperationalError,
SupersetDBAPIProgrammingError,
)
from superset.db_engine_specs.presto import PrestoBaseEngineSpec
from superset.models.sql_lab import Query
from superset.superset_typing import ResultSetColumnType
Expand Down Expand Up @@ -330,9 +335,13 @@
def get_dbapi_exception_mapping(cls) -> dict[type[Exception], type[Exception]]:
# pylint: disable=import-outside-toplevel
from requests import exceptions as requests_exceptions
from trino import exceptions as trino_exceptions

Check warning on line 338 in superset/db_engine_specs/trino.py

View check run for this annotation

Codecov / codecov/patch

superset/db_engine_specs/trino.py#L338

Added line #L338 was not covered by tests

return {
requests_exceptions.ConnectionError: SupersetDBAPIConnectionError,
trino_exceptions.DatabaseError: SupersetDBAPIDatabaseError,
trino_exceptions.OperationalError: SupersetDBAPIOperationalError,
trino_exceptions.ProgrammingError: SupersetDBAPIProgrammingError,
}

@classmethod
Expand Down
Loading