pentaho/pentaho-kettle · error · RuntimeException
The function call getShortFilename is not valid.
Error message
The function call getShortFilename is not valid.
What it means
Thrown by ScriptAddedFunctions.getShortFilename() when the argument contract fails: the function requires exactly one argument that is non-null and non-undefined (ArgList.length == 1 && !isNull && !isUndefined). Zero arguments, extra arguments, or a null/undefined first argument produce this 'The function call getShortFilename is not valid.' RuntimeException before any file access.
Solutions
- Pass exactly one defined, non-null String path: getShortFilename(path).
- Guard in script: if (fn == undefined || fn == null) { skip/log } else { getShortFilename(fn) }.
- Fix upstream steps so the filename field is always populated (defaults, null-if handling).
- Log the offending row (with the row number) to find which record produced the null/undefined value.
- Trim extra arguments — the function signature accepts only one.
Example fix
// before var name = getShortFilename( path, "/data" ); // 'not valid' // after var name = getShortFilename( path );
Defensive patterns
Strategy: type-guard
Validate before calling
// JavaScript
if ( typeof fn === "string" && fn.length > 0 ) { var name = getShortFilename(fn); } Type guard
function isDefinedString(v) { return typeof v === "string" && v !== null; } Try / catch
try { name = getShortFilename(fn); } catch (e) { if (String(e.message).indexOf("is not valid") >= 0) { Logger.logError("getShortFilename needs exactly one non-null string"); name = null; } else { throw e; } } Prevention
- Call with exactly one argument.
- Handle null filename fields before the script step (filters or default values).
- Log row numbers to locate rows producing null/undefined paths.
- Remove leftover extra arguments after script refactors.
When it happens
Trigger: Calling getShortFilename() with no arguments, more than one argument, or a null/undefined filename variable from a JavaScript step (e.g. the incoming row field holding the filename was null).
Common situations: The filename field is absent from some rows so the variable is null; a typo in the variable name leaves it undefined; an extra argument left 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 isFolder is not valid.
- The function call num2str requires 1, 2, or 3 arguments.
- The function call str2date requires 1, 2, 3, or 4 arguments.
- Please provide a valid date to the function call date2str.
- Row.EndOfFileReached
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/037c2c0d7fd63cbc.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:2245
} else {
throw new RuntimeException( "file [" + ArgList[0] + "] can not be found!" );
}
return Filename;
} catch ( IOException e ) {
throw new RuntimeException( "The function call getShortFilename throw an error : " + e.toString() );
} finally {
if ( file != null ) {
try {
file.close();
} catch ( Exception e ) {
// Ignore errors
}
}
}
} else {
throw new RuntimeException( "The function call getShortFilename is not valid." );
}
} catch ( Exception e ) {
throw new RuntimeException( e.toString() );
}
}
public static String getFileExtension( 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)