pentaho/pentaho-kettle · error
The function call appendToFile requires arguments.
Error message
The function call appendToFile requires arguments.
What it means
appendToFile is a custom JavaScript function registered by ScriptValuesAddedFunctions for the ScriptValuesMod (Modified Java Script Value) step in Pentaho Kettle. It requires at least one argument (the text to append and optionally the target filename); when called with zero arguments it throws a Rhino RuntimeException instead of silently doing nothing.
Solutions
- Pass the required arguments: appendToFile(filename, textToAppend) in the script.
- Check that the preceding argument expression (field, variable) is not empty or deleted.
- Wrap the call in a JS guard: if (typeof myText !== 'undefined') appendToFile('log.txt', myText);
Example fix
// before
appendToFile();
// after
appendToFile('output.txt', myTextField + '\n'); Defensive patterns
Strategy: validation
Validate before calling
// in the JS step, before calling
if (typeof myText === 'undefined' || arguments.length < 1) {
throw 'appendToFile needs (filename, text)';
}
appendToFile('out.txt', myText); Prevention
- Never call ScriptValues added functions with zero arguments while testing.
- Keep argument expressions bound to non-deleted fields.
- Wrap optional appends in a typeof undefined check.
When it happens
Trigger: Calling appendToFile() with ArgList.length == 0 from the JavaScript pane of a Modified Java Script Value step.
Common situations: Typing the function name to test it without arguments; a field/variable expression that evaluates to nothing so no arguments are bound; copy-pasted sample code where the call arguments were accidentally deleted.
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 floor requires 1 argument.
- The function call getDayNumber requires 2 arguments.
- The function call getFiscalDate requires 2 arguments.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/9e76a35cb08ec9c1.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:224
throw Context.reportRuntimeError( e.toString() );
}
}
public static void appendToFile( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) {
try {
FileOutputStream file = new FileOutputStream( Context.toString( ArgList[0] ), true );
DataOutputStream out = new DataOutputStream( file );
out.writeBytes( Context.toString( ArgList[1] ) );
out.flush();
out.close();
} catch ( Exception er ) {
throw Context.reportRuntimeError( er.toString() );
}
} else {
throw Context.reportRuntimeError( "The function call appendToFile requires arguments." );
}
}
public static Object getFiscalDate( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 2 ) {
try {
if ( isNull( ArgList ) ) {
return null;
} else if ( isUndefined( ArgList ) ) {
return Context.getUndefinedValue();
}
java.util.Date dIn = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );
Calendar startDate = Calendar.getInstance();
Calendar fisStartDate = Calendar.getInstance();
Calendar fisOffsetDate = Calendar.getInstance();
startDate.setTime( dIn );View on GitHub (pinned to f3058517a1)