pentaho/pentaho-kettle · error · RuntimeException

The function call createFolder is not valid.

Error message

The function call createFolder is not valid.

What it means

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.

Solutions

  1. Catch the RuntimeException in the script and try the same creation with java.nio.file.Files.createDirectories() to get a truthful error message.
  2. Verify the process user can write to the parent directory (ls -ld / chmod).
  3. Normalize the path to a valid VFS URI with forward slashes and a proper scheme.
  4. For remote schemes, verify connection settings and reachability before the script runs.
  5. Use the dedicated 'Create a folder' transformation step or a job 'Create a folder' entry for better error reporting.

Example fix

// before
createFolder('/data/reports/2026-09'); // no write permission on /data/reports
// after
// grant write access or create into a writable base dir:
createFolder('/tmp/reports/2026-09');
Defensive patterns

Strategy: try-catch

Validate before calling

// check write access on the parent before creating
var parent = new java.io.File(path).getParentFile();
if (parent == null || !parent.canWrite()) { throw new Error('no write permission on parent'); }

Type guard

function isVfsUri(p) { return typeof p === 'string' && (/^[a-z]+:\/\//.test(p) || p.startsWith('/')); }

Try / catch

try { createFolder(path); } catch (e) { // generic message hides IOException; use java.nio for the real cause
  java.nio.file.Files.createDirectories(java.nio.file.Paths.get(String(path))); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/df0949c8fcb0912c. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:2004

    }
  }

  public static void createFolder( Bowl bowl, ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {

    try {
      if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {
        FileObject fileObject = null;

        try {
          fileObject = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );
          if ( !fileObject.exists() ) {
            fileObject.createFolder();
          } else {
            throw new RuntimeException( "folder [" + ArgList[0] + "] already exist!" );
          }
        } catch ( IOException e ) {
          throw new RuntimeException( "The function call createFolder is not valid." );
        } finally {
          if ( fileObject != null ) {
            try {
              fileObject.close();
            } catch ( Exception e ) {
              // Ignore errors
            }
          }
        }

      } else {
        throw new RuntimeException( "The function call createFolder is not valid." );
      }
    } catch ( Exception e ) {
      throw new RuntimeException( e.toString() );
    }
  }

View on GitHub (pinned to f3058517a1)