fix: Ensure SupersetError.extra is always a dict (#15848)

Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
John Bodley 2021-07-23 15:19:30 -07:00 committed by GitHub
parent 73b436ab9f
commit 4ba17092fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View File

@ -41,7 +41,7 @@ function DatabaseErrorMessage({
const isVisualization = ['dashboard', 'explore'].includes(source);
const body = (
const body = extra && (
<>
<p>
{t('This may be triggered by:')}
@ -75,13 +75,16 @@ function DatabaseErrorMessage({
</>
);
const copyText = `${message}
const copyText =
extra && extra.issue_codes
? `${message}
${t('This may be triggered by:')}
${extra.issue_codes.map(issueCode => issueCode.message).join('\n')}`;
${extra.issue_codes.map(issueCode => issueCode.message).join('\n')}`
: message;
return (
<ErrorAlert
title={t('%s Error', extra.engine_name || t('DB engine'))}
title={t('%s Error', (extra && extra.engine_name) || t('DB engine'))}
subtitle={subtitle}
level={level}
source={source}

View File

@ -189,7 +189,6 @@ class InvalidPayloadFormatError(SupersetErrorException):
message=message,
error_type=SupersetErrorType.INVALID_PAYLOAD_FORMAT_ERROR,
level=ErrorLevel.ERROR,
extra={},
)
super().__init__(error)

View File

@ -412,7 +412,6 @@ def show_http_exception(ex: HTTPException) -> FlaskResponse:
message=utils.error_msg_from_exception(ex),
error_type=SupersetErrorType.GENERIC_BACKEND_ERROR,
level=ErrorLevel.ERROR,
extra={},
),
],
status=ex.code or 500,
@ -449,7 +448,6 @@ def show_unexpected_exception(ex: Exception) -> FlaskResponse:
message=utils.error_msg_from_exception(ex),
error_type=SupersetErrorType.GENERIC_BACKEND_ERROR,
level=ErrorLevel.ERROR,
extra={},
),
],
)

View File

@ -587,7 +587,7 @@ class TestTestConnectionDatabaseCommand(SupersetTestCase):
connection exc is raised"""
database = get_example_database()
mock_get_sqla_engine.side_effect = SupersetSecurityException(
SupersetError(error_type=500, message="test", level="info", extra={})
SupersetError(error_type=500, message="test", level="info")
)
db_uri = database.sqlalchemy_uri_decrypted
json_payload = {"sqlalchemy_uri": db_uri}