You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zeppelin.apache.org by GitBox <gi...@apache.org> on 2020/03/11 13:33:56 UTC

[GitHub] [zeppelin] alexott commented on a change in pull request #3684: ZEPPELIN-4679: Add API validation for creating interpreter

alexott 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_r390972238
 
 

 ##########
 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:
   I'm not 100% sure that we should use `IOException` here, it's more like "Invalid parameters, or something like". But maybe it will require big changes along the call chain to use something else, so I'm ok with it...

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services