pentaho/pentaho-kettle · error · RhinoRuntimeError

The function call isNum requires 1 argument.

Error message

The function call isNum requires 1 argument.

What it means

The isNum JavaScript function tests whether a single value converts to a number; it returns Boolean.FALSE (rather than throwing) if the conversion fails, but if called with an argument count other than exactly 1 it throws this error via Context.reportRuntimeError. It is purely an arity check in the function's else branch.

Solutions

  1. Call isNum with exactly one argument
  2. To test several values, call isNum once per value
  3. Test the joined/converted value if you need a composite check
  4. Wrap multi-field checks in a small helper function in the script

Example fix

// before
var ok = isNum(fieldA, fieldB); // throws
// after
var ok = isNum(fieldA) && isNum(fieldB);
Defensive patterns

Strategy: type-guard

Validate before calling

function isNumSafe(v) {
  return v !== null && v !== undefined && isNum(v);
}

Type guard

function exactlyOneArg(args) { return args.length === 1; }

Try / catch

try {
  var ok = isNum(field);
} catch (e) {
  if (e.message.indexOf('isNum requires 1 argument') >= 0) {
    // wrong arity — check the call site
  }
}

Prevention

When it happens

Trigger: isNum() with no argument; isNum('1', '2'); isNum applied to multiple fields at once as if it accepted varargs.

Common situations: Treating isNum like a spread validator for a row of fields; a refactor that removed wrapping multiple values into an array before testing.

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

Appendix: source

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

    if ( ArgList.length == 1 ) {
      try {
        if ( isNull( ArgList[0] ) ) {
          return null;
        } else if ( isUndefined( ArgList[0] ) ) {
          return Context.getUndefinedValue();
        }
        double sArg1 = Context.toNumber( ArgList[0] );
        if ( Double.isNaN( sArg1 ) ) {
          return Boolean.FALSE;
        } else {
          return Boolean.TRUE;
        }
      } catch ( Exception e ) {
        return Boolean.FALSE;
      }
    } else {
      throw Context.reportRuntimeError( "The function call isNum requires 1 argument." );
    }
  }

  public static Object isDate( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {

    if ( ArgList.length == 1 ) {
      try {
        if ( isNull( ArgList[0] ) ) {
          return null;
        } else if ( isUndefined( ArgList[0] ) ) {
          return Context.getUndefinedValue();
        }
        /* java.util.Date d = (java.util.Date) */Context.jsToJava( ArgList[0], java.util.Date.class );
        return Boolean.TRUE;
      } catch ( Exception e ) {
        return Boolean.FALSE;
      }

View on GitHub (pinned to f3058517a1)