pentaho/pentaho-kettle · error · RuntimeException
The function call touch requires 1 valid argument.
Error message
The function call touch requires 1 valid argument.
What it means
touch() creates a file or updates its last-modified timestamp, and requires exactly one argument that is a String path. This RuntimeException is thrown when the argument count is not 1 or the argument is not a String (the code checks ArgList.length == 1 && ArgList[0] instanceof String).
Solutions
- Call touch with exactly one String argument: touch('/path/to/file.txt').
- Convert non-string fields first, e.g. touch(fieldName + '') or use a string-typed field.
- Build the full path into a single JavaScript string variable before calling touch().
- Catch the RuntimeException in script if the path may be dynamic and validate it beforehand.
Example fix
// before
touch(fileId); // numeric field
// after
touch('/data/export/' + fileId + '.txt'); Defensive patterns
Strategy: validation
Validate before calling
if (path == null || typeof path !== 'string' || path.length === 0) throw new RuntimeException('touch needs one non-empty string path');
touch(path); Type guard
function isPath(v) { return v != null && (typeof v === 'string' || v instanceof java.lang.String); } Try / catch
try { touch(p); } catch (e) { logError('touch failed: ' + e.message); } Prevention
- Ensure path fields are string-typed in the transformation
- Build full paths into one variable before calling touch()
- Never pass numeric or Date fields directly
When it happens
Trigger: Calling touch() with zero arguments, multiple arguments, or a non-String argument such as a number, Date, or JavaScript null.
Common situations: Passing a transformation field that is not a string type; forgetting the filename argument; concatenating path parts outside the call and accidentally passing extra arguments.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- The function call fileExists requires 1 valid argument.
- The function call copyFile is not valid.
- The function call execProcess is not valid.
- The function call getLastModifiedTime is not valid.
- AccessInputMeta.Exception.FileDoesNotExist
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/65b47f608a392b35.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:961
throw new RuntimeException( e.toString() );
}
} else {
throw new RuntimeException( "The function call str2RegExp requires 2 arguments." );
}
return strArr;
}
public static void touch( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
try {
if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {
File file = new File( (String) ArgList[0] );
boolean success = file.createNewFile();
if ( !success ) {
file.setLastModified( System.currentTimeMillis() );
}
} else {
throw new RuntimeException( "The function call touch requires 1 valid argument." );
}
} catch ( Exception e ) {
throw new RuntimeException( e.toString() );
}
}
public static Object fileExists( 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;
}
File file = new File( (String) ArgList[0] );
return Boolean.valueOf( file.isFile() );
} else {
throw new RuntimeException( "The function call fileExists requires 1 valid argument." );
}View on GitHub (pinned to f3058517a1)