pentaho/pentaho-kettle · error

The function call abs requires 1 argument.

Error message

The function call abs requires 1 argument.

What it means

The abs() helper registered for the ScriptValuesMod step wraps Math.abs but requires exactly 1 numeric argument; calling it with zero arguments (or any count other than 1) throws this Rhino runtime error.

Solutions

  1. Call abs with exactly one numeric argument: abs(myNumber).
  2. Apply it per element if you have an array, not on the array itself.
  3. Ensure the argument expression yields a number (Context.toNumber is applied inside).

Example fix

// before
var a = abs();
// after
var a = abs(myValue);
Defensive patterns

Strategy: validation

Validate before calling

var n = +(myValue);
if (isNaN(n)) n = 0;
var a = abs(n);

Type guard

function isNumber(v){ return typeof v === 'number' && !isNaN(v); }

Prevention

When it happens

Trigger: abs() with no arguments, or abs(a, b) with two, in a Modified Java Script Value step.

Common situations: Migrating from another scripting library where abs accepted a list or array; forgetting the argument when testing; passing an array expecting element-wise results.

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

Appendix: source

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

  }

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

    if ( ArgList.length == 1 ) {
      try {
        if ( isNull( ArgList[0] ) ) {
          return new Double( Double.NaN );
        } else if ( isUndefined( ArgList[0] ) ) {
          return Context.getUndefinedValue();
        } else {
          return new Double( Math.abs( Context.toNumber( ArgList[0] ) ) );
        }
      } catch ( Exception e ) {
        return null;
      }
    } else {
      throw Context.reportRuntimeError( "The function call abs requires 1 argument." );
    }
  }

  public static Object ceil( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 1 ) {
      try {
        if ( isNull( ArgList[0] ) ) {
          return Double.NaN;
        } else if ( isUndefined( ArgList[0] ) ) {
          return Context.getUndefinedValue();
        } else {
          return Math.ceil( Context.toNumber( ArgList[ 0 ] ) );
        }
      } catch ( Exception e ) {
        return null;
      }
    } else {

View on GitHub (pinned to f3058517a1)