prabhjyotsingh commented on a change in pull request #3684: ZEPPELIN-4679: Add
API validation for creating interpreter
URL: https://github.com/apache/zeppelin/pull/3684#discussion_r390990843
##########
File path:
zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSettingManager.java
##########
@@ -767,9 +769,17 @@ private InterpreterSetting inlineCreateNewSetting(String
name, String group,
InterpreterOption option,
Map<String,
InterpreterProperty> properties)
throws IOException {
- if (name.indexOf(".") >= 0) {
- throw new IOException("'.' is invalid for InterpreterSetting name.");
+ if (name == null) {
+ throw new IOException("Interpreter name shouldn't be empty.");
}
+
+ // check if name is valid
+ Pattern pattern = Pattern.compile("^[-_a-zA-Z0-9]+$");
+ Matcher matcher = pattern.matcher(name);
+ if(!matcher.find()){
+ throw new IOException("Interpreter name shouldn't be empty, and can
consist only of: -_a-zA-Z0-9");
Review comment:
Yes, lazy me, I looked up what other APIs are using, and have used the same.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services