pentaho/pentaho-kettle · error · RuntimeException

The function call copyFileis not valid.

Error message

The function call copyFileis not valid.

What it means

Thrown by ScriptAddedFunctions.copyFile when the JavaScript call to copyFile does not receive exactly the arguments the function requires. The function copies a file via KettleVFS but first validates the argument list; a wrong argument count makes the call 'not valid' and it aborts with this RuntimeException.

Solutions

  1. Pass exactly two arguments: copyFile('/path/source.txt', '/path/dest.txt').
  2. Check the JavaScript step code for a missing or extra comma/argument in the copyFile call.
  3. Verify the argument array is built correctly if constructed programmatically before the call.

Example fix

// before
 copyFile('/data/input.csv');
// after
 copyFile('/data/input.csv', '/data/backup/input.csv');
Defensive patterns

Strategy: validation

Validate before calling

// in the JS step, before calling
if (srcPath != null && dstPath != null) {
  copyFile(srcPath, dstPath);
}

Prevention

When it happens

Trigger: Calling copyFile(args, context) from a JavaScript/UDJE step with an ArgList whose length does not match the expected count (source path and destination path), e.g. passing 0, 1, or 3+ arguments, or passing null ArgList.

Common situations: A typo in the JavaScript call (forgot the destination argument), refactored code that dropped a parameter, or dynamically built argument arrays that end up empty.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

        } finally {
          if ( fileSource != null ) {
            try {
              fileSource.close();
            } catch ( Exception e ) {
              // Ignore errors
            }
          }
          if ( fileDestination != null ) {
            try {
              fileDestination.close();
            } catch ( Exception e ) {
              // Ignore errors
            }
          }
        }

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

  public static double getFileSize( Bowl bowl, ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    try {
      if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {
        if ( ArgList[0].equals( null ) ) {
          return 0;
        }
        FileObject file = null;

        try {
          // Source file
          file = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );

View on GitHub (pinned to f3058517a1)