This is an automated email from the ASF dual-hosted git repository. hugh pushed a commit to branch fix-engine-params-ref in repository https://gitbox.apache.org/repos/asf/superset.git
commit 4b426535e98c12b5e0bd99c3a5ba6be2af2d849f Author: hughhhh <[email protected]> AuthorDate: Mon Oct 3 16:44:05 2022 -0400 pull reference --- superset/db_engine_specs/gsheets.py | 17 +++++++++++++++-- superset/models/core.py | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/superset/db_engine_specs/gsheets.py b/superset/db_engine_specs/gsheets.py index 78b42d2b3a..33a2c3d27f 100644 --- a/superset/db_engine_specs/gsheets.py +++ b/superset/db_engine_specs/gsheets.py @@ -31,6 +31,7 @@ from typing_extensions import TypedDict from superset import security_manager from superset.constants import PASSWORD_MASK +from superset.databases.commands.exceptions import DatabaseExtraJSONValidationError from superset.databases.schemas import encrypted_field_properties, EncryptedString from superset.db_engine_specs.sqlite import SqliteEngineSpec from superset.errors import ErrorLevel, SupersetError, SupersetErrorType @@ -209,13 +210,25 @@ class GSheetsEngineSpec(SqliteEngineSpec): spec.components.schema(cls.__name__, schema=cls.parameters_schema) return spec.to_dict()["components"]["schemas"][cls.__name__] + @classmethod + def get_engine_parameters(cls, properties: Dict[str, Any]) -> Dict[str, Any]: + try: + if properties.get("extra"): + return json.loads(properties["extra"]).get("engine_params", {}) + return {} + except TypeError as ex: + raise DatabaseExtraJSONValidationError( + "Unable to parse extra_json data" + ) from ex + @classmethod def validate_parameters( cls, - properties: GSheetsPropertiesType, + properties: Dict[str, Any], ) -> List[SupersetError]: errors: List[SupersetError] = [] - parameters = properties.get("parameters", {}) + + parameters = cls.get_engine_parameters(properties) encrypted_credentials = parameters.get("service_account_info") or "{}" # On create the encrypted credentials are a string, diff --git a/superset/models/core.py b/superset/models/core.py index b0f8bbb772..008230ef48 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -261,7 +261,7 @@ class Database( # When returning the parameters we should use the masked SQLAlchemy URI and the # masked ``encrypted_extra`` to prevent exposing sensitive credentials. masked_uri = make_url_safe(self.sqlalchemy_uri) - masked_encrypted_extra = self.mask_encrypted_extra(self.encrypted_extra) + masked_encrypted_extra = self.masked_encrypted_extra encrypted_config = {} if masked_encrypted_extra is not None: try:
