pentaho/pentaho-kettle · error · RuntimeException

The function call getDigitsOnly requires 1 argument.

Error message

The function call getDigitsOnly requires 1 argument.

What it means

The Script step's added JS function getDigitsOnly is a thin wrapper over Const.getDigitsOnly(String) and accepts exactly one argument: the input string. When the script calls it with any other arity, it throws RuntimeException instead of silently coercing.

Solutions

  1. Call getDigitsOnly with exactly one string argument
  2. Strip extra logic out of the call; filter digits afterwards in JS if needed
  3. Wrap the call in a JS try/catch if argument count is dynamic

Example fix

// before
var digits = getDigitsOnly(phoneNumber, true);
// after
var digits = getDigitsOnly(phoneNumber);
Defensive patterns

Strategy: validation

Validate before calling

// JS in Script step
if (arguments.length !== 1 || typeof arguments[0] !== 'string') {
  throw new Error('getDigitsOnly expects exactly one string argument');
}
var digits = getDigitsOnly(str);

Type guard

// JS
function isSingleString(args) {
  return args.length === 1 && typeof args[0] === 'string';
}

Try / catch

try {
  var digits = getDigitsOnly(str);
} catch (e) {
  Logger.logError('getDigitsOnly failed: ' + e.message);
  digits = null;
}

Prevention

When it happens

Trigger: Calling getDigitsOnly() with zero arguments, or with 2+ arguments (e.g. getDigitsOnly(str, someFlag)), from JavaScript inside the Script step.

Common situations: Porting scripts from JavaScript's String.replace habit and passing a regex/flag; copy-paste from other dialects where a second locale/charset arg was used; typos adding an extra comma.

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/c09eb262e9be5e79. Report an issue: GitHub.

Appendix: source

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

    "createRowCopy", "putRow", "deleteFile", "createFolder", "copyFile", "getFileSize", "isFile", "isFolder",
    "getShortFilename", "getFileExtension", "getParentFoldername", "getLastModifiedTime", "trunc", "truncDate",
    "moveFile", };

  // This is only used for reading, so no concurrency problems.
  // todo: move in the real variables of the step.
  // private static VariableSpace variables = Variables.getADefaultVariableSpace();

  // Functions to Add
  // date2num, num2date,
  // fisc_date, isNull
  //

  public static String getDigitsOnly( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    if ( ArgList.length == 1 ) {
      return Const.getDigitsOnly( (String) ArgList[0] ); // TODO AKRETION ensure
    } else {
      throw new RuntimeException( "The function call getDigitsOnly requires 1 argument." );

    }
  }

  public static boolean LuhnCheck( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {

    boolean returnCode = false;

    if ( ArgList.length == 1 ) {
      if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) {
        try {
          int sum = 0;
          int digit = 0;
          int addend = 0;
          boolean timesTwo = false;
          String argstring = (String) ArgList[0];

View on GitHub (pinned to f3058517a1)