-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
feat(bigquery): Custom message when Service Account doesnt have the correct Roles and Permissions #21838
feat(bigquery): Custom message when Service Account doesnt have the correct Roles and Permissions #21838
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,13 +29,16 @@ | |
from superset.databases.commands.exceptions import ( | ||
DatabaseSecurityUnsafeError, | ||
DatabaseTestConnectionDriverError, | ||
DatabaseTestConnectionFailedError, | ||
DatabaseTestConnectionUnexpectedError, | ||
) | ||
from superset.databases.dao import DatabaseDAO | ||
from superset.databases.utils import make_url_safe | ||
from superset.errors import ErrorLevel, SupersetErrorType | ||
from superset.exceptions import SupersetSecurityException, SupersetTimeoutException | ||
from superset.exceptions import ( | ||
SupersetErrorsException, | ||
SupersetSecurityException, | ||
SupersetTimeoutException, | ||
) | ||
from superset.extensions import event_logger | ||
from superset.models.core import Database | ||
|
||
|
@@ -49,6 +52,7 @@ def __init__(self, data: Dict[str, Any]): | |
|
||
def run(self) -> None: # pylint: disable=too-many-statements | ||
self.validate() | ||
ex_str = "" | ||
uri = self._properties.get("sqlalchemy_uri", "") | ||
if self._model and uri == self._model.safe_sqlalchemy_uri(): | ||
uri = self._model.sqlalchemy_uri_decrypted | ||
|
@@ -117,10 +121,13 @@ def ping(engine: Engine) -> bool: | |
level=ErrorLevel.ERROR, | ||
extra={"sqlalchemy_uri": database.sqlalchemy_uri}, | ||
) from ex | ||
except Exception: # pylint: disable=broad-except | ||
except Exception as ex: # pylint: disable=broad-except | ||
alive = False | ||
# So we stop losing the original message if any | ||
ex_str = str(ex) | ||
|
||
if not alive: | ||
raise DBAPIError(None, None, None) | ||
raise DBAPIError(ex_str or None, None, None) | ||
|
||
# Log succesful connection test with engine | ||
event_logger.log_with_context( | ||
|
@@ -145,7 +152,7 @@ def ping(engine: Engine) -> bool: | |
) | ||
# check for custom errors (wrong username, wrong password, etc) | ||
errors = database.db_engine_spec.extract_errors(ex, context) | ||
raise DatabaseTestConnectionFailedError(errors) from ex | ||
raise SupersetErrorsException(errors) from ex | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Antonio-RiveroMartnez I'm looking into some 500 errors for test connections, and I saw this change. What would happen if I were to change this back to raise the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @eschutho, the problem of doing that is that we would lost the |
||
except SupersetSecurityException as ex: | ||
event_logger.log_with_context( | ||
action=f"test_connection_error.{ex.__class__.__name__}", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original message
-> Custom message after extracting the error.Otherwise the
DatabaseConnectionFailedError
would have the defaultConnection failed ...
message caught from below.