{"record":{"id":"1a2328f434a223a0","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getdigitsonly-requires-1-argument-1a2328","errorCode":null,"errorMessage":"The function call getDigitsOnly requires 1 argument.","messagePattern":"The function call getDigitsOnly requires 1 argument\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":128,"sourceCode":"    GRAND_PARENT\n  }\n\n\n  // This is only used for reading, so no concurrency problems.\n  // todo: move in the real variables of the step.\n  // private static VariableSpace variables = Variables.getADefaultVariableSpace();\n\n  // Functions to Add\n  // date2num, num2date,\n  // fisc_date, isNull\n  //\n\n  public static String getDigitsOnly( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      return Const.getDigitsOnly( Context.toString( ArgList[0] ) );\n    } else {\n      throw Context.reportRuntimeError( \"The function call getDigitsOnly requires 1 argument.\" );\n\n    }\n  }\n\n  public static boolean LuhnCheck( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n\n    boolean returnCode = false;\n\n    if ( ArgList.length == 1 ) {\n      if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) {\n        try {\n          int sum = 0;\n          int digit = 0;\n          int addend = 0;\n          boolean timesTwo = false;\n          String argstring = Context.toString( ArgList[0] );\n","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L110-L146","documentation":"getDigitsOnly is a Rhino-defined JavaScript function in ScriptValuesAddedFunctions. It accepts exactly one argument (the string to filter) and delegates to Const.getDigitsOnly. Any other argument count throws a Rhino RuntimeError: 'The function call getDigitsOnly requires 1 argument.'","triggerScenarios":"Calling getDigitsOnly() with zero arguments or more than one argument from JavaScript in a ScriptValues/Script step.","commonSituations":"Passing a second 'strip spaces' argument by assumption; concatenating the call inside a template and accidentally leaving a trailing comma; calling with no argument when the variable is defined later.","solutions":["Call getDigitsOnly with exactly one string argument.","Pre-strip any other characters yourself if you expected extra options — the function only takes the input string.","Guard the call with a length check or default in the script."],"exampleFix":"// before\nvar out = getDigitsOnly(phone, '-');\n// after\nvar out = getDigitsOnly(phone);","handlingStrategy":"type-guard","validationCode":"// JS guard before calling\nif (typeof v !== 'string') v = String(v);\nvar out = getDigitsOnly(v);","typeGuard":"function safeGetDigitsOnly(v) {\n  if (v === null || v === undefined) return '';\n  return getDigitsOnly(String(v));\n}","tryCatchPattern":"try { var out = getDigitsOnly(v); }\ncatch (e) { if (String(e).indexOf('requires 1 argument') >= 0) { /* fix call arity */ } throw e; }","preventionTips":["Check the ScriptValuesAddedFunctions javadoc for exact signatures","Never pass extra 'option' arguments to these helpers","Coerce variables to strings before string helpers","Test scripts in Spoon's script tester first"],"tags":["javascript","rhino","argument-count","pdi"],"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"}