{"record":{"id":"7952f13db5058823","repo":"pentaho/pentaho-kettle","slug":"the-function-call-createfolder-is-not-valid-7952f1","errorCode":null,"errorMessage":"The function call createFolder is not valid.","messagePattern":"The function call createFolder is not valid\\.","errorType":"exception","errorClass":"RhinoRuntimeError","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":2092,"sourceCode":"    }\n  }\n\n  public static void createFolder( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function 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( getBowl( actualObject ) ).getFileObject( Context.toString( ArgList[0] ) );\n          if ( !fileObject.exists() ) {\n            fileObject.createFolder();\n          } else {\n            Context.reportRuntimeError( \"folder [\" + Context.toString( ArgList[0] ) + \"] already exist!\" );\n          }\n        } catch ( IOException e ) {\n          throw Context.reportRuntimeError( \"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 Context.reportRuntimeError( \"The function call createFolder is not valid.\" );\n      }\n    } catch ( Exception e ) {\n      throw Context.reportRuntimeError( e.toString() );\n    }\n  }\n","sourceCodeStart":2074,"sourceCodeEnd":2110,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2074-L2110","documentation":"createFolder() throws this when creating the directory raises a java.io.IOException. It is thrown from the inner try block after the existence check, meaning the folder did not exist but its creation failed. The original IOException text is discarded, so only this generic message is shown.","triggerScenarios":"fileObject.createFolder() fails: parent directory missing, insufficient write permission on parent, path is an existing non-directory, or the VFS URL is malformed such that resolution succeeds but creation fails.","commonSituations":"Creating nested folders whose parent does not exist (no mkdirs semantics); writing to a read-only mount; permission denied on shared/network drives; typo in scheme causing wrong provider.","solutions":["Create parent directories first (call createFolder() for each level, or use mkdir -p externally).","Verify the process user has write permission on the parent directory.","Confirm the target path does not conflict with an existing file of the same name.","Check the folder path uses a valid VFS URI.","Catch the error in the JS step and log ArgList[0] to identify the failing path."],"exampleFix":"// before\ncreateFolder('/data/out/2026/09'); // parents missing\n// after\ncreateFolder('/data');\ncreateFolder('/data/out');\ncreateFolder('/data/out/2026');\ncreateFolder('/data/out/2026/09');","handlingStrategy":"validation","validationCode":"var parent = path.substring(0, path.lastIndexOf('/'));\nvar pf = new java.io.File(parent);\nif (!pf.exists()) { createFolder(parent); } // ensure parents first\ncreateFolder(path);","typeGuard":null,"tryCatchPattern":"try { createFolder(path); } catch (e) { Logger.logError('createFolder failed for ' + path + ': ' + e.message); }","preventionTips":["Create parent directories level by level","Verify write permission on the parent directory","Use forward slashes / file:// URIs","Confirm the path does not collide with an existing file"],"tags":["javascript","pdi","ioexception","mkdir"],"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"}