This is an automated email from the ASF dual-hosted git repository.

jmclean pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new dcee6ef0ba [#7635] add extra preconditions to Namespace (#7656)
dcee6ef0ba is described below

commit dcee6ef0ba9dc2c0450152c31c3ed89837bb65c0
Author: Yunchi Pang <[email protected]>
AuthorDate: Thu Jul 10 17:40:48 2025 -0700

    [#7635] add extra preconditions to Namespace (#7656)
    
    ### What changes were proposed in this pull request?
    
    Added 2 more precondition checks to `Namespace`:
    1. leading single dot
    2. contains double dot
    
    ### Why are the changes needed?
    
    To enforce a stricter namespace validation.
    Fix: #7635
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing tests.
---
 api/src/main/java/org/apache/gravitino/Namespace.java | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/api/src/main/java/org/apache/gravitino/Namespace.java 
b/api/src/main/java/org/apache/gravitino/Namespace.java
index 85825b7477..7561dd96ea 100644
--- a/api/src/main/java/org/apache/gravitino/Namespace.java
+++ b/api/src/main/java/org/apache/gravitino/Namespace.java
@@ -76,6 +76,10 @@ public class Namespace {
   public static Namespace fromString(String namespace) {
     Preconditions.checkArgument(namespace != null, "Cannot create a namespace 
with null input");
     Preconditions.checkArgument(!namespace.endsWith("."), "Cannot create a 
namespace end with dot");
+    Preconditions.checkArgument(
+        !namespace.startsWith("."), "Cannot create a namespace starting with a 
dot");
+    Preconditions.checkArgument(
+        !namespace.contains(".."), "Cannot create a namespace with an empty 
level");
     if (StringUtils.isBlank(namespace)) {
       return empty();
     }

Reply via email to