betodealmeida commented on a change in pull request #14420:
URL: https://github.com/apache/superset/pull/14420#discussion_r624041758



##########
File path: superset/databases/commands/validate.py
##########
@@ -0,0 +1,125 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from contextlib import closing
+from typing import Any, Dict, Optional
+
+from flask_appbuilder.security.sqla.models import User
+from flask_babel import gettext as __
+from sqlalchemy.engine.url import make_url
+
+from superset.commands.base import BaseCommand
+from superset.databases.commands.exceptions import (
+    DatabaseOfflineError,
+    DatabaseTestConnectionFailedError,
+    InvalidEngineError,
+    InvalidParametersError,
+)
+from superset.databases.dao import DatabaseDAO
+from superset.db_engine_specs import get_engine_specs
+from superset.db_engine_specs.base import BaseParametersMixin
+from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
+from superset.exceptions import SupersetErrorException, SupersetErrorsException
+from superset.models.core import Database
+
+
+class ValidateDatabaseParametersCommand(BaseCommand):
+    def __init__(self, user: User, parameters: Dict[str, Any]):
+        self._actor = user
+        self._properties = parameters.copy()
+        self._model: Optional[Database] = None
+
+    def run(self) -> None:
+        engine = self._properties["engine"]
+        engine_specs = get_engine_specs()
+        if engine not in engine_specs:
+            raise InvalidEngineError(
+                SupersetError(
+                    message=__(
+                        'Engine "%(engine)s" is not a valid engine.', 
engine=engine,
+                    ),
+                    error_type=SupersetErrorType.GENERIC_DB_ENGINE_ERROR,
+                    level=ErrorLevel.ERROR,
+                    extra={"allowed": list(engine_specs), "provided": engine},
+                ),
+            )
+        engine_spec = engine_specs[engine]
+        if not issubclass(engine_spec, BaseParametersMixin):
+            raise InvalidEngineError(
+                SupersetError(
+                    message=__(
+                        'Engine "%(engine)s" cannot be configured through 
parameters.',

Review comment:
       Missing `engine=engine` here, will add.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to