{"record":{"id":"df0949c8fcb0912c","repo":"pentaho/pentaho-kettle","slug":"the-function-call-createfolder-is-not-valid","errorCode":null,"errorMessage":"The function call createFolder is not valid.","messagePattern":"The function call createFolder is not valid\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":2004,"sourceCode":"    }\n  }\n\n  public static void createFolder( Bowl bowl, ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n\n    try {\n      if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {\n        FileObject fileObject = null;\n\n        try {\n          fileObject = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );\n          if ( !fileObject.exists() ) {\n            fileObject.createFolder();\n          } else {\n            throw new RuntimeException( \"folder [\" + ArgList[0] + \"] already exist!\" );\n          }\n        } catch ( IOException e ) {\n          throw new RuntimeException( \"The function call createFolder is not valid.\" );\n        } finally {\n          if ( fileObject != null ) {\n            try {\n              fileObject.close();\n            } catch ( Exception e ) {\n              // Ignore errors\n            }\n          }\n        }\n\n      } else {\n        throw new RuntimeException( \"The function call createFolder is not valid.\" );\n      }\n    } catch ( Exception e ) {\n      throw new RuntimeException( e.toString() );\n    }\n  }\n","sourceCodeStart":1986,"sourceCodeEnd":2022,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L1986-L2022","documentation":"In createFolder(), any IOException from resolving the path or creating the folder is replaced with the generic 'The function call createFolder is not valid.' The original IOException is discarded, so the real cause (bad URI, permission denied, I/O error) must be diagnosed separately.","triggerScenarios":"Calling createFolder() where KettleVFS.getFileObject throws IOException (malformed URI/unsupported scheme) or fileObject.createFolder() raises an IO-level failure such as permission denial on the parent.","commonSituations":"No write permission on the parent directory; malformed VFS URI (backslashes, bad scheme); creating folders on read-only mounts; network filesystems (sftp/webdav) that are unreachable or misconfigured.","solutions":["Catch the RuntimeException in the script and try the same creation with java.nio.file.Files.createDirectories() to get a truthful error message.","Verify the process user can write to the parent directory (ls -ld / chmod).","Normalize the path to a valid VFS URI with forward slashes and a proper scheme.","For remote schemes, verify connection settings and reachability before the script runs.","Use the dedicated 'Create a folder' transformation step or a job 'Create a folder' entry for better error reporting."],"exampleFix":"// before\ncreateFolder('/data/reports/2026-09'); // no write permission on /data/reports\n// after\n// grant write access or create into a writable base dir:\ncreateFolder('/tmp/reports/2026-09');","handlingStrategy":"try-catch","validationCode":"// check write access on the parent before creating\nvar parent = new java.io.File(path).getParentFile();\nif (parent == null || !parent.canWrite()) { throw new Error('no write permission on parent'); }","typeGuard":"function isVfsUri(p) { return typeof p === 'string' && (/^[a-z]+:\\/\\//.test(p) || p.startsWith('/')); }","tryCatchPattern":"try { createFolder(path); } catch (e) { // generic message hides IOException; use java.nio for the real cause\n  java.nio.file.Files.createDirectories(java.nio.file.Paths.get(String(path))); }","preventionTips":["Verify parent-directory write permissions","Use forward slashes and valid schemes","For remote folders test connectivity first"],"tags":["file-io","folder","io-exception","permissions"],"backgroundTag":"mkdir-permission-denied","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"}