pentaho/pentaho-kettle · error · RuntimeException

The function call getProcessCount requires 1 argument.

Error message

The function call getProcessCount requires 1 argument.

What it means

getProcessCount returns the step's processed-row count and requires exactly 1 argument (the step name/type selector). Any other argument count throws RuntimeException; internal errors inside the valid-arity path are swallowed and return 0.

Solutions

  1. Call getProcessCount with exactly one argument as documented
  2. Check the ScriptAddedFunctions javadoc/dialog help for the expected selector value
  3. Wrap dynamic calls in try/catch

Example fix

// before
var n = getProcessCount();
// after
var n = getProcessCount('r');
Defensive patterns

Strategy: validation

Validate before calling

// JS in Script step
if (arguments.length !== 1) {
  throw new Error('getProcessCount expects exactly one argument');
}
var n = getProcessCount('r');

Type guard

// JS
function isSingleArg(args) {
  return args.length === 1;
}

Try / catch

try {
  var n = getProcessCount(sel);
} catch (e) {
  Logger.logError('getProcessCount failed: ' + e.message);
  n = 0;
}

Prevention

When it happens

Trigger: Calling getProcessCount() with zero arguments or multiple arguments in a Script step.

Common situations: Copy-paste from JS snippets where the argument was implicit; scripts converted from older Kettle JavaScript steps with different signatures.

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

Appendix: source

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

        } else if ( strType.equals( "o" ) ) {
          return scm.getLinesOutput();
        } else if ( strType.equals( "r" ) ) {
          return scm.getLinesRead();
        } else if ( strType.equals( "u" ) ) {
          return scm.getLinesUpdated();
        } else if ( strType.equals( "w" ) ) {
          return scm.getLinesWritten();
        } else if ( strType.equals( "e" ) ) {
          return scm.getLinesRejected();
        } else {
          return 0;
        }
      } catch ( Exception e ) {
        // throw new RuntimeException(e.toString());
        return 0;
      }
    } else {
      throw new RuntimeException( "The function call getProcessCount requires 1 argument." );
    }
  }

  public static void writeToLog( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {

    switch ( ArgList.length ) {
      case 1:
        try {
          if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) {
            Object scmO = actualObject.get( "_step_" );
            Script scm = (Script) scmO;
            String strMessage = (String) ArgList[0];
            scm.logDebug( strMessage );
          }
        } catch ( Exception e ) {
          // Ignore errors
        }

View on GitHub (pinned to f3058517a1)