pentaho/pentaho-kettle · error · RuntimeException

The function call fillString requires 2 arguments.

Error message

The function call fillString requires 2 arguments.

What it means

fillString requires exactly two arguments: the single fill character and the repeat count. When ArgList.length != 2 it throws this RuntimeException from the else branch. This check runs before any value validation.

Solutions

  1. Call with exactly two arguments: fillString(char, count).
  2. Add the missing count argument.
  3. Note the argument order is (char, count), not (count, char).

Example fix

// before
var pad = fillString(20);
// after
var pad = fillString(' ', 20);
Defensive patterns

Strategy: validation

Validate before calling

if (arguments.length !== 2) {
  throw new Error('fillString requires exactly 2 arguments: (char, count)');
}
var padded = fillString(fillChar, count);

Type guard

function isFillStringCall(c, n) { return typeof c === 'string' && c.length === 1 && typeof n === 'number'; }

Try / catch

try {
  var padded = fillString(fillChar, count);
} catch (e) {
  if (String(e.message).indexOf('requires 2 arguments') !== -1) {
    throw new Error('Call fillString as fillString(char, count)');
  } else { throw e; }
}

Prevention

When it happens

Trigger: Calling fillString('-') (missing count) or fillString('-', 10, 'x') (extra argument).

Common situations: Forgetting the count and expecting a default; porting code from other padding libraries that take (length, char) in the opposite order and dropping one 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


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/03732bf7edf9bc9f. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:709

        } else if ( isUndefined( ArgList, new int[] { 0, 1 } ) ) {
          return (String) undefinedValue;
        }
        String fillChar = (String) ArgList[0];
        int count = (Integer) ArgList[1];
        if ( fillChar.length() != 1 ) {
          throw new RuntimeException( "Please provide a valid Char to the fillString" );
        } else {
          char[] chars = new char[count];
          while ( count > 0 ) {
            chars[--count] = fillChar.charAt( 0 );
          }
          return new String( chars );
        }
      } catch ( Exception e ) {
        throw new RuntimeException( e.toString() );
      }
    } else {
      throw new RuntimeException( "The function call fillString requires 2 arguments." );
    }
  }

  public static Object isCodepage( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    boolean bRC = false;
    if ( ArgList.length == 2 ) {
      try {
        if ( isNull( ArgList, new int[] { 0, 1 } ) ) {
          return null;
        } else if ( isUndefined( ArgList, new int[] { 0, 1 } ) ) {
          return undefinedValue;
        }
        String strValueToCheck = (String) ArgList[0];
        String strCodePage = (String) ArgList[1];
        byte[] bytearray = strValueToCheck.getBytes();
        CharsetDecoder d = Charset.forName( strCodePage ).newDecoder();
        CharBuffer r = d.decode( ByteBuffer.wrap( bytearray ) );

View on GitHub (pinned to f3058517a1)