pentaho/pentaho-kettle · error · RuntimeException
The function call lpad requires 3 arguments.
Error message
The function call lpad requires 3 arguments.
What it means
lpad() left-pads a string to a target size with a filler string. It validates ArgList.length == 3 inside a try block; if the call does not have exactly three arguments (or another exception occurs), the catch rethrows this RuntimeException and the function returns null.
Solutions
- Call lpad with exactly three arguments: lpad(value, size, filler).
- Ensure size is a positive integer and filler is a string.
- Check the script step log for this message and fix the argument count in the JS source.
- If a default filler is desired, pass it explicitly, e.g. lpad(v, 5, " ").
Example fix
// before var padded = lpad(value, 5); // after var padded = lpad(value, 5, "0");
Defensive patterns
Strategy: validation
Validate before calling
if (value != null && typeof size === "number" && size > 0) { var padded = lpad(value, size, filler); } Type guard
function canLpad(v, size, filler) { return v != null && typeof size === "number" && size > 0 && filler != null && String(filler).length > 0; } Try / catch
try {
var padded = lpad(value, size, filler);
if (padded === null) { /* argument-count failure path */ }
} catch (e) {
Logger.LogBasic("lpad failed: " + e.message);
padded = value;
} Prevention
- Pass all three arguments: value, size, filler.
- Keep size a positive integer.
- Ensure filler is a non-empty string.
- Beware: on failure the function also returns null — check the result.
When it happens
Trigger: Calling lpad(value, size) or lpad(value) in a Script step, or a call whose inner processing throws (non-numeric size, non-string filler), causing the catch block to fire with this message.
Common situations: Forgetting the pad character argument when porting SQL LPAD knowledge that allows a default; passing a variable number of arguments from conditional script code.
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 month requires 1 argument.
- The function call quarter requires 1 argument.
- The function call rpad requires 3 arguments.
- The function call rtrim is not valid :
- The function call week requires 1 argument.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/af0d9261f83a3d5a.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:798
// (String valueToPad, String filler, int size) {
try {
if ( ArgList.length == 3 ) {
if ( isNull( ArgList, new int[] { 0, 1, 2 } ) ) {
return null;
} else if ( isUndefined( ArgList, new int[] { 0, 1, 2 } ) ) {
return (String) undefinedValue;
}
String valueToPad = (String) ArgList[0];
String filler = (String) ArgList[1];
int size = (Integer) ArgList[2];
while ( valueToPad.length() < size ) {
valueToPad = filler + valueToPad;
}
return valueToPad;
}
} catch ( Exception e ) {
throw new RuntimeException( "The function call lpad requires 3 arguments." );
}
return null;
}
public static String rpad( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
try {
if ( ArgList.length == 3 ) {
if ( isNull( ArgList, new int[] { 0, 1, 2 } ) ) {
return null;
} else if ( isUndefined( ArgList, new int[] { 0, 1, 2 } ) ) {
return (String) undefinedValue;
}
String valueToPad = (String) ArgList[0];
String filler = (String) ArgList[1];
int size = (Integer) ArgList[2];
while ( valueToPad.length() < size ) {View on GitHub (pinned to f3058517a1)