You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by yz...@apache.org on 2026/08/23 05:19:31 UTC
(polaris) branch main updated: Fix: CLI 'catalogs create --type external' skips required-flag validation, leaking a pydantic ValidationError (#5353)
This is an automated email from the ASF dual-hosted git repository.
MonkeyCanCode pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push:
new 2e4290860f Fix: CLI 'catalogs create --type external' skips required-flag validation, leaking a pydantic ValidationError (#5353)
2e4290860f is described below
commit 2e4290860f879f4b21d7fecabd2eec79d164d3d2
Author: Xiaodong DENG <xd...@apache.org>
AuthorDate: Sat Aug 22 22:19:25 2026 -0700
Fix: CLI 'catalogs create --type external' skips required-flag validation, leaking a pydantic ValidationError (#5353)
CatalogsCommand.validate() enforces --storage-type and --default-base-location
only for non-external catalogs, but both are required by the SDK model, the
OpenAPI spec, and the server for every catalog type (and by the CLI's own
option-tree hints and user docs). Users creating external catalogs without
either flag hit an opaque pydantic ValidationError at request-build time.
Hoist the two checks out of the else so they apply to CREATE regardless of
catalog_type.
Also updates two existing OAuth/BEARER validation tests to include the
storage flags, so the more-specific auth error still surfaces in isolation.
---
CHANGELOG.md | 1 +
.../python/apache_polaris/cli/command/catalogs.py | 23 ++++++++--------
client/python/tests/test_catalogs_command.py | 31 ++++++++++++++++++++++
3 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4805f87b92..5d656520a9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -46,6 +46,7 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti
### Fixes
+- Python CLI `catalogs create --type external` now validates `--storage-type` and `--default-base-location` up front, matching the behavior for internal catalogs and the flags' documented "(Required)" status. Previously, omitting either produced an opaque pydantic `ValidationError` at request-build time.
- Iceberg REST: server-side JSON processing failures (HTTP 500) now return the standard Iceberg
error envelope (`{"error": {...}}`) instead of a flat `{"code", "message"}` body, so Iceberg
clients can parse the response rather than failing on an off-schema shape.
diff --git a/client/python/apache_polaris/cli/command/catalogs.py b/client/python/apache_polaris/cli/command/catalogs.py
index 4915e4af6d..74ac733a97 100644
--- a/client/python/apache_polaris/cli/command/catalogs.py
+++ b/client/python/apache_polaris/cli/command/catalogs.py
@@ -165,18 +165,17 @@ class CatalogsCommand(Command):
)
if self.catalogs_subcommand == Subcommands.CREATE:
- if self.catalog_type != CatalogType.EXTERNAL.value:
- if not self.storage_type:
- raise CliError(
- f"Missing required argument:"
- f" {Argument.to_flag_name(Arguments.STORAGE_TYPE)}"
- )
- if not self.default_base_location:
- raise CliError(
- f"Missing required argument:"
- f" {Argument.to_flag_name(Arguments.DEFAULT_BASE_LOCATION)}"
- )
- else:
+ if not self.storage_type:
+ raise CliError(
+ f"Missing required argument:"
+ f" {Argument.to_flag_name(Arguments.STORAGE_TYPE)}"
+ )
+ if not self.default_base_location:
+ raise CliError(
+ f"Missing required argument:"
+ f" {Argument.to_flag_name(Arguments.DEFAULT_BASE_LOCATION)}"
+ )
+ if self.catalog_type == CatalogType.EXTERNAL.value:
if self.catalog_authentication_type == AuthenticationType.OAUTH.value:
if (
not self.catalog_token_uri
diff --git a/client/python/tests/test_catalogs_command.py b/client/python/tests/test_catalogs_command.py
index d44c770b4c..6069d60962 100644
--- a/client/python/tests/test_catalogs_command.py
+++ b/client/python/tests/test_catalogs_command.py
@@ -47,6 +47,29 @@ class TestCatalogsCommand(CLITestBase):
),
"--default-base-location",
)
+ # External catalogs also require --storage-type and --default-base-location.
+ self.check_exception(
+ lambda: self.mock_execute(
+ mock_client,
+ ["catalogs", "create", "my-catalog", "--type", "external"],
+ ),
+ "--storage-type",
+ )
+ self.check_exception(
+ lambda: self.mock_execute(
+ mock_client,
+ [
+ "catalogs",
+ "create",
+ "my-catalog",
+ "--type",
+ "external",
+ "--storage-type",
+ "file",
+ ],
+ ),
+ "--default-base-location",
+ )
# Missing catalog name
for sub in ["delete", "get", "update", "summarize"]:
with self.subTest(subcommand=sub):
@@ -114,6 +137,10 @@ class TestCatalogsCommand(CLITestBase):
"my-catalog",
"--type",
"external",
+ "--storage-type",
+ "file",
+ "--default-base-location",
+ "dbl",
"--catalog-connection-type",
"iceberg-rest",
"--catalog-authentication-type",
@@ -134,6 +161,10 @@ class TestCatalogsCommand(CLITestBase):
"my-catalog",
"--type",
"external",
+ "--storage-type",
+ "file",
+ "--default-base-location",
+ "dbl",
"--catalog-connection-type",
"iceberg-rest",
"--catalog-authentication-type",