pentaho/pentaho-kettle · error
The function call copyFileis not valid.
Error message
The function call copyFileis not valid.
What it means
copyFile() throws this (note the missing space, 'copyFileis') when it is called with an argument list that does not match the expected shape of two string path arguments. No copy is attempted. The malformed message is a known artifact of the source string in ScriptValuesAddedFunctions.
Solutions
- Call copyFile with exactly two string arguments: copyFile(src, dst).
- Convert Kettle fields with .stringValue() before passing.
- Null-check both paths before the call.
- Remember the same function also validates types at other branches; fix the call site, not the files.
Example fix
// before copyFile(sourceField.stringValue()); // missing destination // after copyFile(sourceField.stringValue(), '/data/backup/' + sourceField.stringValue());
Defensive patterns
Strategy: validation
Validate before calling
var s = srcField == null ? null : srcField.stringValue();
var d = dstField == null ? null : dstField.stringValue();
if (s == null || d == null) { throw new Error('copyFile needs src and dst strings'); }
copyFile(s, d); Type guard
function isNonEmptyString(v){ return typeof v === 'string' && v.length > 0; } Try / catch
try { copyFile(s, d); } catch (e) { Logger.logError('copyFile misuse: ' + e.message); } Prevention
- Always pass exactly two string arguments
- Convert fields with .stringValue()
- Null-check both paths
- Note the message has a typo ('copyFileis'); it still means wrong argument shape
When it happens
Trigger: Calling copyFile() with zero, one, or three-plus arguments, or with non-string arguments, in a JavaScript step.
Common situations: Forgetting the destination argument; passing field objects instead of .stringValue(); a null variable for the target path due to upstream data issues.
Understand the failure class
Background: "must be a positive integer", "cannot be empty", "invalid argument": how invalid-argument errors work across open-source libraries — this error's family across 33 libraries.
Related errors
- The function call copyFile throw an error :
- The function call getDigitsOnly requires 1 argument.
- The function call getFileSize is not valid.
- The function call indexOf requires 2 or 3 arguments
- The function call LuhnCheck requires 1 argument.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/6bbcbb1d3fa3c509.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:2164
} finally {
if ( fileSource != null ) {
try {
fileSource.close();
} catch ( Exception e ) {
// Ignore errors
}
}
if ( fileDestination != null ) {
try {
fileDestination.close();
} catch ( Exception e ) {
// Ignore errors
}
}
}
} else {
throw Context.reportRuntimeError( "The function call copyFileis not valid." );
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
}
public static double getFileSize( 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 0;
}
FileObject file = null;
try {
// Source file
file = KettleVFS.getInstance( getBowl( actualObject ) ).getFileObject( Context.toString( ArgList[0] ) );View on GitHub (pinned to f3058517a1)