{"record":{"id":"ea0dba817f72e5a8","repo":"pentaho/pentaho-kettle","slug":"the-function-call-execprocess-is-not-valid","errorCode":null,"errorMessage":"The function call execProcess is not valid.","messagePattern":"The function call execProcess is not valid\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":2647,"sourceCode":"        BufferedReader br = new BufferedReader( new InputStreamReader( processrun.getInputStream() ) );\n\n        // Read response lines\n        while ( ( ligne = br.readLine() ) != null ) {\n          buffer.append( ligne );\n        }\n        // if (processrun.exitValue()!=0) throw Context.reportRuntimeError(\"Error while running \" + arguments[0]);\n\n        retval = buffer.toString();\n\n      } catch ( Exception er ) {\n        throw Context.reportRuntimeError( er.toString() );\n      } finally {\n        if ( processrun != null ) {\n          processrun.destroy();\n        }\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call execProcess is not valid.\" );\n    }\n    return retval;\n  }\n\n  public static Boolean isEmpty( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      try {\n        if ( isUndefined( ArgList[0] ) ) {\n          throw new Exception( ArgList[0] + \" is  undefined!\" );\n        }\n        if ( isNull( ArgList[0] ) ) {\n          return Boolean.TRUE;\n        }\n        if ( Context.toString( ArgList[0] ).length() == 0 ) {\n          return Boolean.TRUE;\n        } else {\n          return Boolean.FALSE;","sourceCodeStart":2629,"sourceCodeEnd":2665,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2629-L2665","documentation":"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.","triggerScenarios":"execProcess() with no arguments, passing a plain string where an array of command tokens is expected, or extra arguments in the JS step.","commonSituations":"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.","solutions":["Pass the command as an array of tokens: execProcess(['/bin/sh','-c','ls -l']).","Verify the argument is non-null and correctly typed before calling.","Do not rely on shell built-ins directly; invoke a shell explicitly.","Check your Kettle/PDI version's expected signature for execProcess and match it exactly."],"exampleFix":"// before\nvar out = execProcess('ls -l');\n// after\nvar out = execProcess(['/bin/sh', '-c', 'ls -l']);","handlingStrategy":"validation","validationCode":"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; } }","typeGuard":"function isCmdArray(v) { return Array.isArray(v) && v.length > 0 && v.every(function(t){ return typeof t === 'string'; }); }","tryCatchPattern":"try { out = execProcess(cmdArray); } catch (e) { Logger.LogError('execProcess invalid: ' + e.message); out = null; }","preventionTips":["Pass an array of command tokens, not a single shell string","Invoke a shell explicitly for shell features: ['/bin/sh','-c', ...]","Null-check the variables forming the command"],"tags":["javascript","scripting","process-execution","argument-validation"],"backgroundTag":"invalid-argument","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}