Repository navigation
Open
Labels
bugSomething isn't working
Description
Describe the bug
Unable to delete a comment of a volume after initially assigning a comment
To Reproduce
import string
from random import choice
from typing import Any, AsyncGenerator, Generator
import pytest
from testcontainers.core.container import DockerContainer
from testcontainers.core.wait_strategies import HttpWaitStrategy
from unitycatalog.client import (
ApiClient,
CatalogsApi,
Configuration,
CreateCatalog,
CreateSchema,
CreateVolumeRequestContent,
SchemasApi,
UpdateVolumeRequestContent,
VolumeInfo,
VolumesApi,
VolumeType,
)
@pytest.fixture
def docker_container() -> Generator[DockerContainer, Any, None]:
unity_catalog: DockerContainer = (
DockerContainer(image="unitycatalog/unitycatalog:v0.5.0")
.with_bind_ports(container=8080, host=8080)
.with_env(key="storage-root.tables", value="/tmp/uc/tables")
.waiting_for(
strategy=HttpWaitStrategy(
port=8080, path="/api/2.1/unity-catalog/catalogs"
).for_status_code(code=200)
)
)
unity_catalog.start()
yield unity_catalog
unity_catalog.stop()
@pytest.fixture
async def api_client(
docker_container: DockerContainer,
) -> AsyncGenerator[ApiClient, Any]:
config = Configuration()
config.host = (
f"http://{docker_container.get_container_host_ip()}:8080"
"/api/2.1/unity-catalog"
)
api_client = ApiClient(configuration=config)
yield api_client
await api_client.close()
@pytest.fixture
async def catalog_name(api_client: ApiClient) -> AsyncGenerator[str, Any]:
catalog_name: str = "".join(
choice(seq=string.ascii_lowercase) for _ in range(10)
)
catalog_api = CatalogsApi(api_client=api_client)
create_catalog = CreateCatalog(
name=catalog_name, storage_root="/tmp/uc/catalogs"
)
await catalog_api.create_catalog(create_catalog=create_catalog)
yield catalog_name
@pytest.fixture
async def database(
api_client: ApiClient, catalog_name: str
) -> AsyncGenerator[str, Any]:
database_name: str = "".join(
choice(seq=string.ascii_lowercase) for _ in range(10)
)
schemas_api = SchemasApi(api_client=api_client)
schema = CreateSchema(
name=database_name, catalog_name=catalog_name, comment=None
)
await schemas_api.create_schema(create_schema=schema)
yield database_name
@pytest.fixture
async def volume(
api_client: ApiClient,
catalog_name: str,
database: str,
) -> AsyncGenerator[str, Any]:
volumes_api = VolumesApi(api_client=api_client)
volume_name: str = "".join(
choice(seq=string.ascii_lowercase) for _ in range(10)
)
create_volume_request_content = CreateVolumeRequestContent(
catalog_name=catalog_name,
schema_name=database,
name=volume_name,
volume_type=VolumeType.MANAGED,
comment="This is a volume comment",
)
await volumes_api.create_volume(
create_volume_request_content=create_volume_request_content
)
yield volume_name
async def test_set_volume_comment_empty_string(
api_client: ApiClient, catalog_name: str, database: str, volume: str
):
update_volume_request_content = UpdateVolumeRequestContent(comment=None)
volumes_api = VolumesApi(api_client=api_client)
volume_info: VolumeInfo = await volumes_api.update_volume(
name=f"{catalog_name}.{database}.{volume}",
update_volume_request_content=update_volume_request_content,
)
assert not volume_info.commentSetting the volume comment to an empty string results in the following error
E pydantic_core._pydantic_core.ValidationError: 1 validation error for UpdateVolumeRequestContent
E comment
E String should have at least 1 character [type=string_too_short, input_value='', input_type=str]
E For further information visit https://errors.pydantic.dev/2.12/v/string_too_shortExpected behavior
Volume comment is deleted when setting it to none.
System [please complete the following information]:
- OS: macOS 26.6
- Unity Catalog: 0.5.0
Additional context
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
fix: allow empty comment to clear volume comment (unitycatalog#1727)