mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
chore(database): Creating helper make_url_safe to wrap potential errors (#19526)
* Creating helper make_url_safe to wrap potential errors * Fixing imports * Fixing imports again * Adding comment * Linting * Fixing test * Fixing test again... * Fixing import
This commit is contained in:
@@ -19,10 +19,10 @@ from typing import Optional, Type
|
||||
|
||||
from flask_babel import lazy_gettext as _
|
||||
from marshmallow import ValidationError
|
||||
from sqlalchemy.engine.url import make_url
|
||||
from sqlalchemy.exc import ArgumentError
|
||||
|
||||
from superset import security_manager
|
||||
from superset.databases.commands.exceptions import DatabaseInvalidError
|
||||
from superset.databases.utils import make_url_safe
|
||||
from superset.models.core import Database
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ def sqlalchemy_uri_validator(
|
||||
Check if a user has submitted a valid SQLAlchemy URI
|
||||
"""
|
||||
try:
|
||||
make_url(uri.strip())
|
||||
except (ArgumentError, AttributeError) as ex:
|
||||
make_url_safe(uri.strip())
|
||||
except DatabaseInvalidError as ex:
|
||||
raise exception(
|
||||
[
|
||||
_(
|
||||
|
||||
Reference in New Issue
Block a user