pentaho/pentaho-kettle · error
The function call isFile is not valid.
Error message
The function call isFile is not valid.
What it means
isFile() is a JavaScript scripting function added by PDI (Kettle)'s ScriptValuesMod step. It resolves its single argument to a VFS FileObject and reports whether it is a regular file. Before doing any I/O it validates the JavaScript argument list; if the call does not have exactly one non-null, non-undefined argument it throws 'The function call isFile is not valid.' via Context.reportRuntimeError, which surfaces as a JavaScript runtime error inside the transform.
Solutions
- Ensure isFile is called with exactly one argument, e.g. isFile(filename)
- Check the argument variable is defined and not null/undefined before calling (use JS typeof / null checks or a 'If field value is null' step)
- Correct upstream field mappings so the filename field is populated
- Wrap the call in try/catch inside the script to handle bad input gracefully
Example fix
// before var ok = isFile(); // after var path = 'file:///data/input.csv'; var ok = isFile(path);
Defensive patterns
Strategy: validation
Validate before calling
// in the JS step, before calling
if (typeof myFile === 'undefined' || myFile === null) {
throw new Error('myFile must be a non-null path string');
}
var result = isFile(myFile); Type guard
function isNonEmptyString(v) { return typeof v === 'string' && v.length > 0; } Try / catch
try { var ok = isFile(path); } catch (e) { // log and continue row
ok = false; } Prevention
- Always pass exactly one argument to the VFS helper functions
- Null-check fields with a 'If field value is null' step before scripting
- Use typeof checks in the script for variables sourced from fields
- Keep sample/test data so undefined variables surface early
When it happens
Trigger: Calling isFile() with zero arguments, more than one argument, or with an argument that is JavaScript null or undefined (e.g. a field variable that was never populated). The guard is `ArgList.length == 1 && !isNull(ArgList[0]) && !isUndefined(ArgList[0])`.
Common situations: A typo in the variable name inside a JavaScript step (the variable is undefined), a field upstream that did not produce a value, copy-pasted sample code calling isFile with a missing parameter, or passing the result of another function that returned undefined.
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
- The function call dateAdd requires 3 arguments.
- The function call dateDiff requires 3 arguments.
- The function call fillString requires 2 arguments.
- The function call fireToDB requires 2 arguments.
- The function call getFileExtension is not valid.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/d11f6ec7b8acab7b.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:2250
}
} else {
Context.reportRuntimeError( "file [" + Context.toString( ArgList[0] ) + "] can not be found!" );
}
return isafile;
} catch ( IOException e ) {
throw Context.reportRuntimeError( "The function call is File throw an error : " + e.toString() );
} finally {
if ( file != null ) {
try {
file.close();
} catch ( Exception e ) {
// Ignore errors
}
}
}
} else {
throw Context.reportRuntimeError( "The function call isFile is not valid." );
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
}
public static boolean isFolder( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
try {
if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {
if ( ArgList[0].equals( null ) ) {
return false;
}
FileObject file = null;
try {
// Source file
file = KettleVFS.getInstance( getBowl( actualObject ) ).getFileObject( Context.toString( ArgList[0] ) );View on GitHub (pinned to f3058517a1)