pentaho/pentaho-kettle · error
The function call getLastModifiedTime is not valid.
Error message
The function call getLastModifiedTime is not valid.
What it means
getLastModifiedTime is a Rhino JavaScript helper function added by ScriptValuesAddedFunctions. It requires exactly one argument (a file name string or File object); any other argument count or type falls through to the final else and this reportRuntimeError is thrown. The error means the JS script called getLastModifiedTime with an invalid signature.
Solutions
- Pass exactly one argument that is a valid file path string, e.g. getLastModifiedTime('/tmp/data.csv').
- Guard the argument in script: if (path != null && typeof path == 'string') { ... } before calling.
- Check that the file-related variables coming from previous steps are actually populated (log them before the call).
- Wrap the call in try/catch inside the script and return a default (e.g. null) when arguments are invalid.
Example fix
// before var ts = getLastModifiedTime(); // after var ts = (filename != null) ? getLastModifiedTime(filename.toString()) : null;
Defensive patterns
Strategy: validation
Validate before calling
function safeGetLastModified(p) { if (p == null || typeof p !== 'string' || p.length === 0) return null; try { return getLastModifiedTime(p); } catch (e) { return null; } } Type guard
function isFilePath(v) { return v != null && typeof v === 'string' && v.length > 0; } Try / catch
try { ts = getLastModifiedTime(path); } catch (e) { Logger.LogError('getLastModifiedTime failed: ' + e.message); ts = null; } Prevention
- Always pass exactly one string path argument
- Null-check variables sourced from upstream steps
- Log argument values before calling file helpers
When it happens
Trigger: Calling getLastModifiedTime() with zero arguments, with more than one argument, or with a first argument that cannot be converted to a java.io.File (e.g. a number, null, or a non-string object) from a JavaScript step (Modified Java Script Value).
Common situations: Passing a JS variable that is undefined/null because an upstream field was empty; forgetting the argument entirely; passing a Path-like or JavaScript string built from concatenation that ends up not coercible; copy-pasted script code assuming a different helper signature.
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
- Error in isEmpty function:
- ScriptValuesMod.Log.CouldNotAddDefaultConstants
- The function call copyFile is not valid.
- The function call execProcess is not valid.
- The function call isEmpty is not valid
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/3c5585566fa21f91.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:2465
Context.reportRuntimeError( "file [" + Context.toString( ArgList[0] ) + "] can not be found!" );
}
return lastmodifiedtime;
} catch ( IOException e ) {
throw Context.reportRuntimeError( "The function call getLastModifiedTime throw an error : "
+ e.toString() );
} finally {
if ( file != null ) {
try {
file.close();
} catch ( Exception e ) {
// Ignore errors
}
}
}
} else {
throw Context.reportRuntimeError( "The function call getLastModifiedTime is not valid." );
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
}
public static Object trunc( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
try {
// 1 argument: normal truncation of numbers
//
if ( ArgList.length == 1 ) {
if ( isNull( ArgList[0] ) ) {
return null;
} else if ( isUndefined( ArgList[0] ) ) {
return Context.getUndefinedValue();
}
View on GitHub (pinned to f3058517a1)