Skip to content

fix: preserve empty property values in CLI - #3745

Merged
kevinjqliu merged 1 commit into
apache:mainfrom
mj006648:fix/cli-empty-property
Aug 3, 2026
Merged

fix: preserve empty property values in CLI#3745
kevinjqliu merged 1 commit into
apache:mainfrom
mj006648:fix/cli-empty-property

Conversation

@mj006648

@mj006648 mj006648 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

The properties get table and properties get namespace commands used a truthy check for property lookups. As a result, an existing property with an empty string value was reported as missing.

This changes both lookups to check explicitly for None, preserving empty strings while keeping the existing error for missing properties.

Related to #3713.

Are these changes tested?

Yes. Added CLI regression tests for empty table and namespace property values.

  • make lint
  • uv run python -m pytest tests/cli/test_console.py

Are there any user-facing changes?

Yes. The table and namespace property commands now return an existing empty string value instead of raising NoSuchPropertyException.

@kevinjqliu kevinjqliu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great catch!

Comment thread pyiceberg/cli/console.py
Comment on lines 329 to 336
if property_name:
if property_value := namespace_properties.get(property_name):
property_value = namespace_properties.get(property_name)
if property_value is not None:
output.text(property_value)
else:
raise NoSuchPropertyException(f"Could not find property {property_name} on namespace {identifier}")
else:
output.describe_properties(namespace_properties)

@kevinjqliu kevinjqliu Aug 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slight nit: i think we can simplify this whole block like so

    if not property_name:
        output.describe_properties(namespace_properties)
        return

    property_value = namespace_properties.get(property_name)
    if property_value is None:
        raise NoSuchPropertyException(f"Could not find property {property_name} on namespace {identifier}")

    output.text(property_value)

but this can be a follow up PR 😄

@kevinjqliu
kevinjqliu merged commit af337ba into apache:main Aug 3, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants