diff --git a/grove/__about__.py b/grove/__about__.py index 8bf832f..5aa4356 100644 --- a/grove/__about__.py +++ b/grove/__about__.py @@ -1,6 +1,6 @@ """Grove metadata.""" -__version__ = "1.5.1" +__version__ = "1.6.0" __title__ = "grove" __license__ = "Mozilla Public License 2.0" __copyright__ = "Copyright 2023 HashiCorp, Inc." diff --git a/grove/connectors/snowflake/common.py b/grove/connectors/snowflake/common.py index 41c177a..6652f2e 100644 --- a/grove/connectors/snowflake/common.py +++ b/grove/connectors/snowflake/common.py @@ -124,7 +124,10 @@ def schema(self) -> Optional[str]: :return: The "schema" portion of the connector's configuration. """ try: - return self.configuration.schema + # The trailing underscore is due to a limitation in Pydantic < 2.0 where + # 'schema' is an internal field. We automatically remap these internal + # fields with a trailing underscore while we migrate to Pydantic >= 2.0 + return self.configuration.schema_ except AttributeError: return "SNOWFLAKE" diff --git a/grove/models.py b/grove/models.py index 878383d..b029c87 100644 --- a/grove/models.py +++ b/grove/models.py @@ -143,6 +143,19 @@ def _decode_fields(cls, values): # noqa: B902 Other encoding schemes may be supported in future, but for now only base64 is supported. """ + # This is a horrible hack to allow fields with names that mask Pydantic + # internals. This can be removed once Grove is updated to use Pydantic >= 2. + INTERNAL_FIELDS = ["schema"] + + for field in INTERNAL_FIELDS: + value = values.get(field, None) + if value is None: + continue + + # Remap the field name to contain a trailing underscore. + values[f"{field}_"] = value + del values[field] + for field, encoding in values.get("encoding", {}).items(): # If the secret is externally stored decoding will be performed after the # secret has been retrieved. Right now, this field should not exist as it