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

pinal pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/master by this push:
     new a4b022936 ATLAS-4956 : Creating tag with name description throws 
java.lang.ClassCastException
a4b022936 is described below

commit a4b02293668bd9befb6ae80c53324254a8d75f07
Author: priyanshi-shah26 <priyanshi.s...@freestoneinfotech.com>
AuthorDate: Tue Jan 21 11:11:45 2025 +0530

    ATLAS-4956 : Creating tag with name description throws 
java.lang.ClassCastException
    
    Signed-off-by: Pinal Shah <pinal.s...@freestoneinfotech.com>
---
 intg/src/main/java/org/apache/atlas/AtlasErrorCode.java      |  1 +
 .../repository/store/graph/v2/AtlasAbstractDefStoreV2.java   | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java 
b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
index a5430ce44..97d83b6fe 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
@@ -178,6 +178,7 @@ public enum AtlasErrorCode {
     IMPORT_INVALID_ZIP_ENTRY(400, "ATLAS-400-00-09F", "{0}: invalid zip entry. 
Reason: {1}"),
     LINEAGE_ON_DEMAND_NOT_ENABLED(400, "ATLAS-400-00-100", "Lineage on demand 
config: {0} is not enabled"),
     INVALID_TOPIC_NAME(400, "ATLAS-400-00-101", "Unsupported topic name : 
{0}"),
+    UNSUPPORTED_TYPE_NAME(400, "ATLAS-400-00-102", "Unsupported {0} name. 
Names such as 'description','version','options','name','servicetype' are not 
supported"),
 
     UNAUTHORIZED_ACCESS(403, "ATLAS-403-00-001", "{0} is not authorized to 
perform {1}"),
 
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasAbstractDefStoreV2.java
 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasAbstractDefStoreV2.java
index 3dab120f9..17ddc94d4 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasAbstractDefStoreV2.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasAbstractDefStoreV2.java
@@ -36,8 +36,11 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.regex.Pattern;
 
 /**
@@ -53,6 +56,7 @@ import java.util.regex.Pattern;
     private static final String  INTERNAL_NAME_REGEX   = "__" + NAME_REGEX;
     private static final Pattern NAME_PATTERN          = 
Pattern.compile(NAME_REGEX);
     private static final Pattern INTERNAL_NAME_PATTERN = 
Pattern.compile(INTERNAL_NAME_REGEX);
+    private static final Set<String> INVALID_TYPEDEF_NAMES_LIST = new 
HashSet<String>(Arrays.asList("description", "version", "options", "name", 
"servicetype"));
 
     public static final String ALLOW_RESERVED_KEYWORDS = 
"atlas.types.allowReservedKeywords";
 
@@ -107,6 +111,10 @@ import java.util.regex.Pattern;
         if (!isValidName(typeDef.getName())) {
             throw new 
AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID_FORMAT, typeDef.getName(), 
typeDef.getCategory().name());
         }
+        // To validate unsupported typeDef name
+        if (isInvalidTypeDefName(typeDef.getName())) {
+            throw new AtlasBaseException(AtlasErrorCode.UNSUPPORTED_TYPE_NAME, 
typeDef.getCategory().name());
+        }
 
         try {
             final boolean allowReservedKeywords = 
ApplicationProperties.get().getBoolean(ALLOW_RESERVED_KEYWORDS, true);
@@ -158,4 +166,8 @@ import java.util.regex.Pattern;
             LOG.debug("<== AtlasAbstractDefStoreV1.deleteByGuid({}, {})", 
guid, preDeleteResult);
         }
     }
+    
+    public boolean isInvalidTypeDefName(String typeName) {
+        return INVALID_TYPEDEF_NAMES_LIST.contains(typeName);
+    }
 }

Reply via email to