pentaho/pentaho-kettle · error · RuntimeException
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 to the transformation log and accepts 1 argument (message, default log level) or 2 arguments (log level, message). A switch over ArgList.length falls through to default and throws RuntimeException for any other count.
Solutions
- Combine message parts into one string: writeToLog('l', msg1 + msg2)
- Use the 1-arg form writeToLog(msg) when default level is fine
- Never pass a throwable; format it into the message
Example fix
// before writeToLog(LogWriter.LOG_LEVEL_BASIC, 'x=', value, ' y=', other); // after writeToLog(LogWriter.LOG_LEVEL_BASIC, 'x=' + value + ' y=' + other);
Defensive patterns
Strategy: validation
Validate before calling
// JS in Script step
if (arguments.length < 1 || arguments.length > 2) {
throw new Error('writeToLog expects (msg) or (level, msg)');
}
writeToLog(level, msg); Type guard
// JS
function validWriteToLogArgs(args) {
return args.length === 1 || args.length === 2;
} Try / catch
try {
writeToLog(LogWriter.LOG_LEVEL_BASIC, msg);
} catch (e) {
// logging failed - fail safe, do not kill the transformation
} Prevention
- Concatenate all message fragments into one string
- Match 1-arg (message only) or 2-arg (level, message) forms exactly
- Never pass exceptions/throwables directly; format them first
When it happens
Trigger: Calling writeToLog() with zero arguments or with 3+ arguments, e.g. writeToLog(level, msg, detail) in a Script step.
Common situations: Passing varargs messages (writeToLog('a', 'b', 'c')); forgetting to concatenate message parts; porting from log4j-style calls with throwable argument.
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 getDigitsOnly requires 1 argument.
- The function call getFiscalDate requires 2 arguments.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/159cef99874e3196.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:320
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 new RuntimeException( "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( undefinedValue ) ) {
return true;
}
}
return false;
}
private static boolean isNull( Object ArgList ) {
return isNull( new Object[] { ArgList }, new int[] { 0 } );View on GitHub (pinned to f3058517a1)