Skip to content

Commit

Permalink
ATLAS-4956 : Creating tag with name description throws java.lang.Clas…
Browse files Browse the repository at this point in the history
…sCastException

Signed-off-by: Pinal Shah <[email protected]>
  • Loading branch information
priyanshi-shah26 authored and pinal-shah committed Jan 30, 2025
1 parent ad72e3c commit a4b0229
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
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;

/**
Expand All @@ -53,6 +56,7 @@ abstract class AtlasAbstractDefStoreV2<T extends AtlasBaseTypeDef> implements At
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";

Expand Down Expand Up @@ -107,6 +111,10 @@ public void validateType(AtlasBaseTypeDef typeDef) throws AtlasBaseException {
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);
Expand Down Expand Up @@ -158,4 +166,8 @@ public void deleteByGuid(String guid, AtlasVertex preDeleteResult) throws AtlasB
LOG.debug("<== AtlasAbstractDefStoreV1.deleteByGuid({}, {})", guid, preDeleteResult);
}
}

public boolean isInvalidTypeDefName(String typeName) {
return INVALID_TYPEDEF_NAMES_LIST.contains(typeName);
}
}

0 comments on commit a4b0229

Please sign in to comment.