{"record":{"id":"f694299e351847d4","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getprocesscount-requires-1-argument","errorCode":null,"errorMessage":"The function call getProcessCount requires 1 argument.","messagePattern":"The function call getProcessCount requires 1 argument\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":273,"sourceCode":"        } else if ( strType.equals( \"o\" ) ) {\n          return scm.getLinesOutput();\n        } else if ( strType.equals( \"r\" ) ) {\n          return scm.getLinesRead();\n        } else if ( strType.equals( \"u\" ) ) {\n          return scm.getLinesUpdated();\n        } else if ( strType.equals( \"w\" ) ) {\n          return scm.getLinesWritten();\n        } else if ( strType.equals( \"e\" ) ) {\n          return scm.getLinesRejected();\n        } else {\n          return 0;\n        }\n      } catch ( Exception e ) {\n        // throw new RuntimeException(e.toString());\n        return 0;\n      }\n    } else {\n      throw new RuntimeException( \"The function call getProcessCount requires 1 argument.\" );\n    }\n  }\n\n  public static void writeToLog( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n\n    switch ( ArgList.length ) {\n      case 1:\n        try {\n          if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) {\n            Object scmO = actualObject.get( \"_step_\" );\n            Script scm = (Script) scmO;\n            String strMessage = (String) ArgList[0];\n            scm.logDebug( strMessage );\n          }\n        } catch ( Exception e ) {\n          // Ignore errors\n        }","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L255-L291","documentation":"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.","triggerScenarios":"Calling getProcessCount() with zero arguments or multiple arguments in a Script step.","commonSituations":"Copy-paste from JS snippets where the argument was implicit; scripts converted from older Kettle JavaScript steps with different signatures.","solutions":["Call getProcessCount with exactly one argument as documented","Check the ScriptAddedFunctions javadoc/dialog help for the expected selector value","Wrap dynamic calls in try/catch"],"exampleFix":"// before\nvar n = getProcessCount();\n// after\nvar n = getProcessCount('r');","handlingStrategy":"validation","validationCode":"// JS in Script step\nif (arguments.length !== 1) {\n  throw new Error('getProcessCount expects exactly one argument');\n}\nvar n = getProcessCount('r');","typeGuard":"// JS\nfunction isSingleArg(args) {\n  return args.length === 1;\n}","tryCatchPattern":"try {\n  var n = getProcessCount(sel);\n} catch (e) {\n  Logger.logError('getProcessCount failed: ' + e.message);\n  n = 0;\n}","preventionTips":["Consult the ScriptAddedFunctions docs for the expected selector argument","Do not call with implicit/zero arguments","Test scripts against a sample transformation run"],"tags":["kettle","javascript","arity","rows"],"backgroundTag":"missing-required-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"}