diff --git a/ibis-server/app/model/__init__.py b/ibis-server/app/model/__init__.py index 24e93282a..cc80b5a35 100644 --- a/ibis-server/app/model/__init__.py +++ b/ibis-server/app/model/__init__.py @@ -82,7 +82,7 @@ class ClickHouseConnectionInfo(BaseModel): port: SecretStr database: SecretStr user: SecretStr - password: SecretStr + password: SecretStr | None = None class MSSqlConnectionInfo(BaseModel): @@ -90,7 +90,7 @@ class MSSqlConnectionInfo(BaseModel): port: SecretStr database: SecretStr user: SecretStr - password: SecretStr + password: SecretStr | None = None driver: str = Field(default="ODBC Driver 18 for SQL Server") tds_version: str = Field(default="8.0", alias="TDS_Version") kwargs: dict[str, str] | None = Field( @@ -103,7 +103,7 @@ class MySqlConnectionInfo(BaseModel): port: SecretStr database: SecretStr user: SecretStr - password: SecretStr + password: SecretStr | None = None ssl_mode: SecretStr | None = Field(alias="sslMode", default=None) ssl_ca: SecretStr | None = Field(alias="sslCA", default=None) kwargs: dict[str, str] | None = Field( @@ -120,7 +120,7 @@ class PostgresConnectionInfo(BaseModel): port: SecretStr = Field(examples=[5432]) database: SecretStr user: SecretStr - password: SecretStr + password: SecretStr | None = None class SnowflakeConnectionInfo(BaseModel): diff --git a/ibis-server/app/model/data_source.py b/ibis-server/app/model/data_source.py index d1aa3b41e..81cf34bad 100644 --- a/ibis-server/app/model/data_source.py +++ b/ibis-server/app/model/data_source.py @@ -118,7 +118,7 @@ def get_clickhouse_connection(info: ClickHouseConnectionInfo) -> BaseBackend: port=int(info.port.get_secret_value()), database=info.database.get_secret_value(), user=info.user.get_secret_value(), - password=info.password.get_secret_value(), + password=(info.password and info.password.get_secret_value()), ) @classmethod @@ -128,8 +128,11 @@ def get_mssql_connection(cls, info: MSSqlConnectionInfo) -> BaseBackend: port=info.port.get_secret_value(), database=info.database.get_secret_value(), user=info.user.get_secret_value(), - password=cls._escape_special_characters_for_odbc( - info.password.get_secret_value() + password=( + info.password + and cls._escape_special_characters_for_odbc( + info.password.get_secret_value() + ) ), driver=info.driver, TDS_Version=info.tds_version, @@ -147,7 +150,7 @@ def get_mysql_connection(cls, info: MySqlConnectionInfo) -> BaseBackend: port=int(info.port.get_secret_value()), database=info.database.get_secret_value(), user=info.user.get_secret_value(), - password=info.password.get_secret_value(), + password=(info.password and info.password.get_secret_value()), **kwargs, ) @@ -158,7 +161,7 @@ def get_postgres_connection(info: PostgresConnectionInfo) -> BaseBackend: port=int(info.port.get_secret_value()), database=info.database.get_secret_value(), user=info.user.get_secret_value(), - password=info.password.get_secret_value(), + password=(info.password and info.password.get_secret_value()), ) @staticmethod @@ -189,7 +192,9 @@ def _escape_special_characters_for_odbc(value: str) -> str: @staticmethod def _create_ssl_context(info: ConnectionInfo) -> Optional[ssl.SSLContext]: ssl_mode = ( - info.ssl_mode.get_secret_value() if hasattr(info, "ssl_mode") else None + info.ssl_mode.get_secret_value() + if hasattr(info, "ssl_mode") and info.ssl_mode + else None ) if ssl_mode == SSLMode.VERIFY_CA and not info.ssl_ca: