pentaho/pentaho-kettle · error · RuntimeException
The function call appendToFile requires arguments.
Error message
The function call appendToFile requires arguments.
What it means
Arity guard in ScriptAddedFunctions.appendToFile: the script invoked the function with a null/undefined or empty argument list, but it needs (filename, content) to open the FileOutputStream in append mode and write the bytes. The guard fires before any file is touched.
Solutions
- Pass the filename (and content) explicitly: appendToFile(filename, content)
- Guard undefined variables in JS before the call
- Wrap in try/catch and fall back to a default message
Example fix
// before
appendToFile();
// after
appendToFile('/tmp/out.log', 'entry: ' + value); Defensive patterns
Strategy: validation
Validate before calling
// JS in Script step
if (arguments.length === 0) {
throw new Error('appendToFile needs at least a filename');
}
appendToFile(filename, content); Type guard
// JS
function hasArgs(args) {
return args.length > 0;
} Try / catch
try {
appendToFile(file, msg);
} catch (e) {
Logger.logError('appendToFile failed: ' + e.message);
} Prevention
- Never build argument arrays conditionally such that they can end up empty
- Default-define file/content variables at the top of the script
- Check for undefined variables before calls
When it happens
Trigger: Calling appendToFile() with no arguments from a Script step; a variable holding the content being undefined so the dynamically-built argument list is empty.
Common situations: Logging scripts where the message variable is undefined/null and got dropped; generated scripts with conditional argument construction that skipped all args.
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 abs requires 1 argument.
- The function call ceil requires 1 argument.
- The function call getDigitsOnly requires 1 argument.
- The function call getFiscalDate requires 2 arguments.
- The function call getProcessCount requires 1 argument.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/471cb3a434fb1373.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:206
throw new RuntimeException( e.toString() );
}
}
public static void appendToFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) {
try {
FileOutputStream file = new FileOutputStream( (String) ArgList[0], true );
DataOutputStream out = new DataOutputStream( file );
out.writeBytes( (String) ArgList[1] );
out.flush();
out.close();
} catch ( Exception er ) {
throw new RuntimeException( er.toString() );
}
} else {
throw new RuntimeException( "The function call appendToFile requires arguments." );
}
}
public static Object getFiscalDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
if ( ArgList.length == 2 ) {
try {
if ( isNull( ArgList ) ) {
return null;
} else if ( isUndefined( ArgList ) ) {
return undefinedValue;
}
java.util.Date dIn = (java.util.Date) ArgList[0];
Calendar startDate = Calendar.getInstance();
Calendar fisStartDate = Calendar.getInstance();
Calendar fisOffsetDate = Calendar.getInstance();
startDate.setTime( dIn );View on GitHub (pinned to f3058517a1)