pentaho/pentaho-kettle · error
The function call writeToLog requires 1 or 2 arguments.
Error message
The function call writeToLog requires 1 or 2 arguments.
What it means
writeToLog writes a message to the transformation log, optionally with a log level as the first argument, so it accepts exactly 1 or 2 arguments; any other argument count (including zero, or three) hits the default branch of its switch and throws this error.
Solutions
- Call with 1 or 2 arguments: writeToLog('message') or writeToLog('logRowlevel', 'message').
- Use a valid log level constant string ('Basic','Detailed','Error','Debug','Rowlevel') as first argument when using two.
- Remove extra parameters; concatenate them into the message instead.
Example fix
// before
writeToLog('Debug', 'value=', val, 'id=', id);
// after
writeToLog('Debug', 'value=' + val + ' id=' + id); Defensive patterns
Strategy: validation
Validate before calling
function safeLog(level, msg) {
if (arguments.length < 1) return;
if (arguments.length === 1) writeToLog(String(arguments[0]));
else writeToLog(String(level), String(msg));
}
safeLog('Debug', 'value=' + val); Prevention
- Always pass 1 (message) or 2 (level, message) arguments, never more.
- Concatenate multiple values into a single message string.
- Use standard level strings: Basic, Detailed, Error, Debug, Rowlevel.
When it happens
Trigger: writeToLog() with no arguments, or writeToLog(a, b, c) with three arguments, in a Modified Java Script Value step.
Common situations: Adding a message parameter to an existing 2-arg call (level, message) producing 3 args; calling it to test without arguments; passing the level and message in the wrong slots then appending extras.
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 appendToFile requires arguments.
- The function call ceil requires 1 argument.
- The function call floor requires 1 argument.
- The function call getDayNumber requires 2 arguments.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/713384a49388804f.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:338
scm.logBasic( strMessage );
} else if ( strType.equals( "d" ) ) {
scm.logDebug( strMessage );
} else if ( strType.equals( "l" ) ) {
scm.logDetailed( strMessage );
} else if ( strType.equals( "e" ) ) {
scm.logError( strMessage );
} else if ( strType.equals( "m" ) ) {
scm.logMinimal( strMessage );
} else if ( strType.equals( "r" ) ) {
scm.logRowlevel( strMessage );
}
}
} catch ( Exception e ) {
// Ignore errors
}
break;
default:
throw Context.reportRuntimeError( "The function call writeToLog requires 1 or 2 arguments." );
}
}
private static boolean isUndefined( Object ArgList ) {
return isUndefined( new Object[] { ArgList }, new int[] { 0 } );
}
private static boolean isUndefined( Object[] ArgList, int[] iArrToCheck ) {
for ( int i = 0; i < iArrToCheck.length; i++ ) {
if ( ArgList[iArrToCheck[i]].equals( Context.getUndefinedValue() ) ) {
return true;
}
}
return false;
}
private static boolean isNull( Object ArgList ) {
return isNull( new Object[] { ArgList }, new int[] { 0 } );View on GitHub (pinned to f3058517a1)