pentaho/pentaho-kettle · error
The function call getParentFoldername is not valid.
Error message
The function call getParentFoldername is not valid.
What it means
getParentFoldername() is a JavaScript function exposed by the ScriptValuesMod step. It enforces an exact single-argument contract before any VFS access; calls without exactly one non-null, non-undefined argument throw 'The function call getParentFoldername is not valid.' as a JavaScript runtime error.
Solutions
- Pass exactly one path argument
- Guard the variable against null/undefined before the call
- Repair the upstream step so the path field is populated
- Catch the runtime error in script and default the result
Example fix
// before var p = getParentFoldername(); // after var p = (fpath != null) ? getParentFoldername(fpath) : null;
Defensive patterns
Strategy: validation
Validate before calling
if (typeof fpath === 'undefined' || fpath === null) {
throw new Error('fpath required for getParentFoldername');
}
var p = getParentFoldername(fpath); Type guard
function hasValue(v) { return v !== undefined && v !== null; } Try / catch
try { var p = getParentFoldername(fpath); } catch (e) { p = null; } Prevention
- Exactly one argument per call
- Null-check variables sourced from fields
- Fix upstream nulls early in the transform
- Use defensive try/catch in script steps
When it happens
Trigger: Invoking getParentFoldername() with zero or multiple arguments, or with a null/undefined first argument (guard: ArgList.length == 1 && !isNull && !isUndefined).
Common situations: Undefined folder/filename variable from a typo or missing upstream field, null values flowing through the row stream, or wrong arity after refactoring the script.
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/64133d81ecea6555.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:2417
Context.reportRuntimeError( "file [" + Context.toString( ArgList[0] ) + "] can not be found!" );
}
return foldername;
} catch ( IOException e ) {
throw Context.reportRuntimeError( "The function call getParentFoldername throw an error : "
+ e.toString() );
} finally {
if ( file != null ) {
try {
file.close();
} catch ( Exception e ) {
// Ignore errors
}
}
}
} else {
throw Context.reportRuntimeError( "The function call getParentFoldername is not valid." );
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
}
public static String getLastModifiedTime( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
try {
if ( ArgList.length == 2 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {
if ( ArgList[0].equals( null ) ) {
return null;
}
FileObject file = null;
try {
// Source file
file = KettleVFS.getInstance( getBowl( actualObject ) ).getFileObject( Context.toString( ArgList[0] ) );View on GitHub (pinned to f3058517a1)