pentaho/pentaho-kettle · error · RuntimeException

The function call isFolder is not valid.

Error message

The function call isFolder is not valid.

What it means

Thrown by ScriptAddedFunctions.isFolder() when the argument contract is violated: the function requires exactly one argument that is neither null nor undefined (ArgList.length == 1 && !isNull && !isUndefined). Any other shape — zero arguments, multiple arguments, or a null/undefined first argument — triggers this 'function call is not valid' RuntimeException before any filesystem access.

Solutions

  1. Call isFolder with exactly one argument and ensure it is a non-null, defined String before the call.
  2. Add a script-side guard: if (p != undefined && p != null) { isFolder(p) } else { /* handle */ }.
  3. Trace why the variable is undefined/null — check the row layout and prior steps feeding the field.
  4. Provide a default value for optional paths (e.g. p = p || "/default/dir").
  5. If your field can legitimately be null, handle that case explicitly before invoking the function.

Example fix

// before
var ok = isFolder( rowNum, path ); // 'The function call isFolder is not valid.'
// after
var ok = isFolder( path ); // exactly one argument
Defensive patterns

Strategy: type-guard

Validate before calling

// JavaScript
if ( typeof p === "string" && p.length > 0 ) { var ok = isFolder(p); }

Type guard

function isDefinedString(v) { return typeof v === "string" && v !== null; }

Try / catch

try { ok = isFolder(p); } catch (e) { if (String(e.message).indexOf("is not valid") >= 0) { Logger.logError("Bad arguments to isFolder"); ok = false; } else { throw e; } }

Prevention

When it happens

Trigger: Calling isFolder() with no arguments, with two or more arguments, or with null/undefined as the first argument from a JavaScript step (e.g. isFolder(varThatTurnedOutUndefined)).

Common situations: A script variable was never assigned (undefined) because an earlier field was missing from the row; copy-paste left an extra argument; a field value was null so the guard trips even though the developer expected null to return false (the inner ArgList[0].equals(null) branch is unreachable in practice).

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/883211f0da4df292. Report an issue: GitHub.

Appendix: source

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

            }
          } else {
            throw new RuntimeException( "folder [" + ArgList[0] + "] can not be found!" );
          }
          return isafolder;
        } catch ( IOException e ) {
          throw new RuntimeException( "The function call isFolder throw an error : " + e.toString() );
        } finally {
          if ( file != null ) {
            try {
              file.close();
            } catch ( Exception e ) {
              // Ignore errors
            }
          }
        }

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

  public static String getShortFilename( 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 null;
        }
        FileObject file = null;

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

View on GitHub (pinned to f3058517a1)