pentaho/pentaho-kettle · error
The function call lpad requires 3 arguments.
Error message
The function call lpad requires 3 arguments.
What it means
The lpad() function in the JavaScript step pads a string on the left to a given size using a filler string. It requires exactly 3 arguments (value, size, filler); if the call throws for any reason — most commonly an argument count mismatch — it reports this error. Note the message is misleading: any exception in the body also produces it.
Solutions
- Call lpad() with exactly 3 arguments: value, target size, filler string.
- Null-check the value before padding.
- Verify the size argument is a number and the filler is a non-empty string.
- If a 2-argument call is desired, add the filler explicitly, e.g. lpad(field, 5, '0').
Example fix
// before var padded = lpad(myField, 10); // after var padded = lpad(myField, 10, '0');
Defensive patterns
Strategy: validation
Validate before calling
if (myField == null) throw 'lpad: value is null'; var padded = lpad(String(myField), 10, '0');
Type guard
function canLpad(v, size, filler) { return v != null && typeof size === 'number' && typeof filler === 'string' && filler.length > 0; } Try / catch
try { var padded = lpad(String(myField), 10, '0'); } catch (e) { var padded = String(myField); } Prevention
- Always supply all 3 arguments: value, size, filler
- Remember the error message is generic — any lpad failure shows it
- Coerce value with String() and size with a numeric literal
- Test scripts in a dry-run transformation before production
When it happens
Trigger: Calling lpad() in a modified JavaScript step with fewer than 3 arguments (e.g. lpad(field, 5)), or with arguments whose conversion fails (null value, non-numeric size).
Common situations: Scripts written against a different signature (some libraries' lpad takes only 2 args with a default filler), copy-pasted SQL LPAD with optional filler, or a null incoming field value.
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 rpad requires 3 arguments.
- The function call rtrim is not valid :
- Error in isEmpty function:
- Script.Log.CouldNotAddDefaultConstants
- ScriptValuesMod.Log.CouldNotAddDefaultConstants
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/b66522d07e7463a9.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:828
// (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) Context.getUndefinedValue();
}
String valueToPad = Context.toString( ArgList[0] );
String filler = Context.toString( ArgList[1] );
int size = (int) Context.toNumber( ArgList[2] );
while ( valueToPad.length() < size ) {
valueToPad = filler + valueToPad;
}
return valueToPad;
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( "The function call lpad requires 3 arguments." );
}
return null;
}
public static String rpad( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function 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) Context.getUndefinedValue();
}
String valueToPad = Context.toString( ArgList[0] );
String filler = Context.toString( ArgList[1] );
int size = (int) Context.toNumber( ArgList[2] );
while ( valueToPad.length() < size ) {View on GitHub (pinned to f3058517a1)