pentaho/pentaho-kettle · error

The function call getDigitsOnly requires 1 argument.

Error message

The function call getDigitsOnly requires 1 argument.

What it means

getDigitsOnly is a Rhino-defined JavaScript function in ScriptValuesAddedFunctions. It accepts exactly one argument (the string to filter) and delegates to Const.getDigitsOnly. Any other argument count throws a Rhino RuntimeError: 'The function call getDigitsOnly requires 1 argument.'

Solutions

  1. Call getDigitsOnly with exactly one string argument.
  2. Pre-strip any other characters yourself if you expected extra options — the function only takes the input string.
  3. Guard the call with a length check or default in the script.

Example fix

// before
var out = getDigitsOnly(phone, '-');
// after
var out = getDigitsOnly(phone);
Defensive patterns

Strategy: type-guard

Validate before calling

// JS guard before calling
if (typeof v !== 'string') v = String(v);
var out = getDigitsOnly(v);

Type guard

function safeGetDigitsOnly(v) {
  if (v === null || v === undefined) return '';
  return getDigitsOnly(String(v));
}

Try / catch

try { var out = getDigitsOnly(v); }
catch (e) { if (String(e).indexOf('requires 1 argument') >= 0) { /* fix call arity */ } throw e; }

Prevention

When it happens

Trigger: Calling getDigitsOnly() with zero arguments or more than one argument from JavaScript in a ScriptValues/Script step.

Common situations: Passing a second 'strip spaces' argument by assumption; concatenating the call inside a template and accidentally leaving a trailing comma; calling with no argument when the variable is defined later.

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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:128

    GRAND_PARENT
  }


  // 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( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 1 ) {
      return Const.getDigitsOnly( Context.toString( ArgList[0] ) );
    } else {
      throw Context.reportRuntimeError( "The function call getDigitsOnly requires 1 argument." );

    }
  }

  public static boolean LuhnCheck( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function 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 = Context.toString( ArgList[0] );

View on GitHub (pinned to f3058517a1)