From b4ff749bc54dfe71cb26a1582468c9181bf33f6d Mon Sep 17 00:00:00 2001 From: Andrew Xie Date: Mon, 9 Feb 2026 14:43:10 -0500 Subject: [PATCH 1/2] fix: Prevent empty namespace creation --- ice/src/main/java/com/altinity/ice/cli/Main.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ice/src/main/java/com/altinity/ice/cli/Main.java b/ice/src/main/java/com/altinity/ice/cli/Main.java index 014d2ec..ddf8094 100644 --- a/ice/src/main/java/com/altinity/ice/cli/Main.java +++ b/ice/src/main/java/com/altinity/ice/cli/Main.java @@ -628,7 +628,15 @@ void createNamespace( boolean createNamespaceIfNotExists) throws IOException { try (RESTCatalog catalog = loadCatalog()) { - CreateNamespace.run(catalog, Namespace.of(name.split("[.]")), createNamespaceIfNotExists); + String[] split = name.split("[.]"); + for (String level : split) { + if (level.isEmpty()) { + throw new IllegalArgumentException( + "Invalid namespace name: '.' cannot separate empty names"); + } + } + + CreateNamespace.run(catalog, Namespace.of(split), createNamespaceIfNotExists); } } From 7cf131ccba478939845dd95b4353f3f26b36f54a Mon Sep 17 00:00:00 2001 From: Andrew Xie Date: Fri, 13 Feb 2026 16:53:17 -0500 Subject: [PATCH 2/2] Add scenario test for empty namespace --- .../scenarios/empty-namespace/run.sh.tmpl | 23 +++++++++++++++++++ .../scenarios/empty-namespace/scenario.yaml | 6 +++++ .../main/java/com/altinity/ice/cli/Main.java | 3 +++ 3 files changed, 32 insertions(+) create mode 100644 ice-rest-catalog/src/test/resources/scenarios/empty-namespace/run.sh.tmpl create mode 100644 ice-rest-catalog/src/test/resources/scenarios/empty-namespace/scenario.yaml diff --git a/ice-rest-catalog/src/test/resources/scenarios/empty-namespace/run.sh.tmpl b/ice-rest-catalog/src/test/resources/scenarios/empty-namespace/run.sh.tmpl new file mode 100644 index 0000000..e37d93d --- /dev/null +++ b/ice-rest-catalog/src/test/resources/scenarios/empty-namespace/run.sh.tmpl @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +echo "Running empty namespace test..." + +for namespace in $INVALID_NAMESPACES; do + if ! {{ICE_CLI}} -c {{CLI_CONFIG}} create-namespace "$namespace"; then + echo "OK create-namespace failed as expected" + else + echo "FAIL create-namespace should have failed with invalid namespace: $namespace" + exit 1 + fi +done + +namespaces=$(curl {{CATALOG_URI}}/v1/namespaces) +expected='{"namespaces":[],"next-page-token":null}' + +if [ "$namespaces" == "$expected" ]; then + echo "OK list of namespaces is empty" +else + echo "FAIL list of namespaces is not empty: $namespaces" + exit 1 +fi diff --git a/ice-rest-catalog/src/test/resources/scenarios/empty-namespace/scenario.yaml b/ice-rest-catalog/src/test/resources/scenarios/empty-namespace/scenario.yaml new file mode 100644 index 0000000..13cdd6c --- /dev/null +++ b/ice-rest-catalog/src/test/resources/scenarios/empty-namespace/scenario.yaml @@ -0,0 +1,6 @@ +name: "Empty Namespace Creation" +description: "Ensures empty namespaces cannot be created" + +env: + # space-separate list of namespaces that should cause an error with create-namespace + INVALID_NAMESPACES: ".. .test .a. a..b" \ No newline at end of file diff --git a/ice/src/main/java/com/altinity/ice/cli/Main.java b/ice/src/main/java/com/altinity/ice/cli/Main.java index ddf8094..a10e1da 100644 --- a/ice/src/main/java/com/altinity/ice/cli/Main.java +++ b/ice/src/main/java/com/altinity/ice/cli/Main.java @@ -635,6 +635,9 @@ void createNamespace( "Invalid namespace name: '.' cannot separate empty names"); } } + if (split.length == 0) { + throw new IllegalArgumentException("Invalid namespace name: name cannot be empty"); + } CreateNamespace.run(catalog, Namespace.of(split), createNamespaceIfNotExists); }