{"record":{"id":"54e4faa8085f4706","repo":"pentaho/pentaho-kettle","slug":"the-function-call-luhncheck-requires-1-argument","errorCode":null,"errorMessage":"The function call LuhnCheck requires 1 argument.","messagePattern":"The function call LuhnCheck 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":154,"sourceCode":"            } else {\n              addend = digit;\n            }\n            sum += addend;\n            timesTwo = !timesTwo;\n          }\n\n          int modulus = sum % 10;\n          if ( modulus == 0 ) {\n            returnCode = true;\n          }\n        } catch ( Exception e ) {\n          // No Need to throw exception\n          // This means that input can not be parsed to Integer\n        }\n\n      }\n    } else {\n      throw new RuntimeException( \"The function call LuhnCheck requires 1 argument.\" );\n\n    }\n    return returnCode;\n  }\n\n  public static int indexOf( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n\n    int returnIndex = -1;\n\n    if ( ArgList.length == 2 || ArgList.length == 3 ) {\n      if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) {\n        String string = (String) ArgList[0];\n        String subString = (String) ArgList[1];\n\n        int fromIndex = 0;\n        if ( ArgList.length == 3 ) {\n          fromIndex = (int) Math.round( (Double) ArgList[2] );","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L136-L172","documentation":"Arity guard in ScriptAddedFunctions.LuhnCheck: the function was invoked from a script with an ArgList whose length is not 1, so the Luhn checksum cannot be computed. The input at fault is the script's argument list; the intended single string argument must be numeric-parsable, otherwise the function silently returns false.","triggerScenarios":"Calling LuhnCheck() with zero args or with multiple args (e.g. LuhnCheck(num, expectedCheckDigit)) inside a Script step.","commonSituations":"Assuming the check digit can be passed separately; translating pseudocode that splits the number into parts.","solutions":["Call LuhnCheck with exactly one argument containing the full number","Pre-compute/strip any extra values in JS before the call","Use a JS wrapper that enforces arity"],"exampleFix":"// before\nvar ok = LuhnCheck(cardNum, 7);\n// after\nvar ok = LuhnCheck(cardNum);","handlingStrategy":"validation","validationCode":"// JS in Script step\nif (arguments.length !== 1) {\n  throw new Error('LuhnCheck expects exactly one argument');\n}\nvar ok = LuhnCheck(String(cardNum));","typeGuard":"// JS\nfunction isSingleArg(args) {\n  return args.length === 1;\n}","tryCatchPattern":"try {\n  var ok = LuhnCheck(cardNum);\n} catch (e) {\n  Logger.logError('LuhnCheck failed: ' + e.message);\n  ok = false;\n}","preventionTips":["Pass the full number including check digit as a single string","Do not split number/check digit into separate arguments","Review Kettle added-functions javadoc for exact signatures"],"tags":["kettle","javascript","arity","luhn"],"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"}