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

  1. Call lpad with exactly three arguments: lpad(value, size, filler).
  2. Ensure size is a positive integer and filler is a string.
  3. Check the script step log for this message and fix the argument count in the JS source.
  4. 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

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


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)