{"record":{"id":"f704894cd9fd5d75","repo":"pentaho/pentaho-kettle","slug":"arglist-0-is-not-a-folder","errorCode":null,"errorMessage":"[ + ArgList[0] + ] is not a folder!","messagePattern":"\\[ \\+ ArgList\\[0\\] \\+ \\] is not a folder!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":2185,"sourceCode":"\n  public static boolean isFolder( Bowl bowl, ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n    try {\n      if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {\n        if ( ArgList[0].equals( null ) ) {\n          return false;\n        }\n        FileObject file = null;\n\n        try {\n          // Source file\n          file = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );\n          boolean isafolder = false;\n          if ( file.exists() ) {\n            if ( file.getType().equals( FileType.FOLDER ) ) {\n              isafolder = true;\n            } else {\n              throw new RuntimeException( \"[\" + ArgList[0] + \"] is not a folder!\" );\n            }\n          } else {\n            throw new RuntimeException( \"folder [\" + ArgList[0] + \"] can not be found!\" );\n          }\n          return isafolder;\n        } catch ( IOException e ) {\n          throw new RuntimeException( \"The function call isFolder throw an error : \" + e.toString() );\n        } finally {\n          if ( file != null ) {\n            try {\n              file.close();\n            } catch ( Exception e ) {\n              // Ignore errors\n            }\n          }\n        }\n\n      } else {","sourceCodeStart":2167,"sourceCodeEnd":2203,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L2167-L2203","documentation":"Thrown by ScriptAddedFunctions.isFolder() when the VFS object at ArgList[0] exists but its FileType is not FileType.FOLDER — i.e. the caller passed a regular file where a directory was expected. The function resolves the path via KettleVFS, confirms it exists, then validates the type; a file (or other non-folder type) fails the check and aborts with this RuntimeException.","triggerScenarios":"Calling isFolder(path) from a JavaScript step with a path that resolves to an existing regular file (e.g. /data/report.txt) instead of a directory.","commonSituations":"Typos dropping the trailing directory name so the path points at a file; config fields where the user entered a file path in a 'folder' input; VFS symlinks or name collisions where a file was created where a folder was expected.","solutions":["Check the path with isFile()/ls and confirm whether it is a file; remove or rename the file if the directory was intended.","Correct the path passed to isFolder() to point at an actual directory (add the missing path segment or trailing name).","If the path may be either, branch in the script: if(isFile(p)) {...} else if(isFolder(p)) {...}.","Create the intended directory first (mkdir) if it does not exist and the file is unrelated.","Validate the path ends at a directory before calling, e.g. via Java Files.isDirectory() or a KettleVFS type check."],"exampleFix":"// before\nvar ok = isFolder( \"/data/report.txt\" ); // throws: [/data/report.txt] is not a folder!\n// after\nvar ok = isFolder( \"/data/reports\" ); // existing directory","handlingStrategy":"validation","validationCode":"// before calling\nvar f = getFileSize(p); // or isFile(p); confirm p points to a directory before isFolder(p)","typeGuard":"function looksLikeDirectory(p) { return typeof p === \"string\" && !/\\.[A-Za-z0-9]+$/.test(p); }","tryCatchPattern":"try { ok = isFolder(p); } catch (e) { if (String(e.message).indexOf(\"not a folder\") >= 0) { /* handle file-instead-of-folder */ } else { throw e; } }","preventionTips":["Verify with isFile() that the path is not a file before calling isFolder().","Avoid free-text folder inputs; use folder-browser validated config fields.","Watch for files accidentally created at the same path as the intended folder.","Document that isFolder throws rather than returning false for wrong-type paths."],"tags":["java","vfs","filesystem","wrong-type","path"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}