pentaho/pentaho-kettle · error

The function call execProcess is not valid.

Error message

The function call execProcess is not valid.

What it means

execProcess(commandArray) runs an external process and returns its output. The 'not valid' error is thrown when the argument contract is not met — the code only proceeds when the argument list matches its expected shape (a command, typically a string array); otherwise it throws before executing anything.

Solutions

  1. Pass the command as an array of tokens: execProcess(['/bin/sh','-c','ls -l']).
  2. Verify the argument is non-null and correctly typed before calling.
  3. Do not rely on shell built-ins directly; invoke a shell explicitly.
  4. Check your Kettle/PDI version's expected signature for execProcess and match it exactly.

Example fix

// before
var out = execProcess('ls -l');
// after
var out = execProcess(['/bin/sh', '-c', 'ls -l']);
Defensive patterns

Strategy: validation

Validate before calling

function safeExec(cmd) { if (!Array.isArray(cmd) || cmd.length === 0) return null; for (var i = 0; i < cmd.length; i++) { if (typeof cmd[i] !== 'string') return null; } try { return execProcess(cmd); } catch (e) { return null; } }

Type guard

function isCmdArray(v) { return Array.isArray(v) && v.length > 0 && v.every(function(t){ return typeof t === 'string'; }); }

Try / catch

try { out = execProcess(cmdArray); } catch (e) { Logger.LogError('execProcess invalid: ' + e.message); out = null; }

Prevention

When it happens

Trigger: execProcess() with no arguments, passing a plain string where an array of command tokens is expected, or extra arguments in the JS step.

Common situations: Passing one long command line with shell operators expecting shell parsing; forgetting the array form ('ls -l' vs ['ls','-l']); variables resolving to null making the signature check fail.

Understand the failure class

Background: "must be a positive integer", "cannot be empty", "invalid argument": how invalid-argument errors work across open-source libraries — this error's family across 33 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/ea0dba817f72e5a8. Report an issue: GitHub.

Appendix: source

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

        BufferedReader br = new BufferedReader( new InputStreamReader( processrun.getInputStream() ) );

        // Read response lines
        while ( ( ligne = br.readLine() ) != null ) {
          buffer.append( ligne );
        }
        // if (processrun.exitValue()!=0) throw Context.reportRuntimeError("Error while running " + arguments[0]);

        retval = buffer.toString();

      } catch ( Exception er ) {
        throw Context.reportRuntimeError( er.toString() );
      } finally {
        if ( processrun != null ) {
          processrun.destroy();
        }
      }
    } else {
      throw Context.reportRuntimeError( "The function call execProcess is not valid." );
    }
    return retval;
  }

  public static Boolean isEmpty( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 1 ) {
      try {
        if ( isUndefined( ArgList[0] ) ) {
          throw new Exception( ArgList[0] + " is  undefined!" );
        }
        if ( isNull( ArgList[0] ) ) {
          return Boolean.TRUE;
        }
        if ( Context.toString( ArgList[0] ).length() == 0 ) {
          return Boolean.TRUE;
        } else {
          return Boolean.FALSE;

View on GitHub (pinned to f3058517a1)