{"record":{"id":"15b91cd2901344a6","repo":"pentaho/pentaho-kettle","slug":"the-function-call-luhncheck-requires-1-argument-15b91c","errorCode":null,"errorMessage":"The function call LuhnCheck requires 1 argument.","messagePattern":"The function call LuhnCheck 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":172,"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 Context.reportRuntimeError( \"The function call LuhnCheck requires 1 argument.\" );\n\n    }\n    return returnCode;\n  }\n\n  public static int indexOf( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n\n    int returnIndex = -1;\n\n    if ( ArgList.length == 2 || ArgList.length == 3 ) {\n      if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) {\n        String string = Context.toString( ArgList[0] );\n        String subString = Context.toString( ArgList[1] );\n\n        int fromIndex = 0;\n        if ( ArgList.length == 3 ) {\n          fromIndex = (int) Math.round( Context.toNumber( ArgList[2] ) );","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L154-L190","documentation":"LuhnCheck validates a number string using the Luhn algorithm and requires exactly one argument. When called with zero or multiple arguments it throws a Rhino RuntimeError: 'The function call LuhnCheck requires 1 argument.'","triggerScenarios":"Calling LuhnCheck() with an argument count other than 1 from JavaScript in a Script step, e.g. LuhnCheck(card) where card is undefined still counts as 1 arg, but LuhnCheck() or LuhnCheck(a, b) fails.","commonSituations":"Credit card validation scripts passing extra format options; forgetting to pass the variable; copying a call signature from a different utility.","solutions":["Pass exactly one argument (the numeric string) to LuhnCheck.","Ensure the variable is defined before the call so you're not passing nothing/extra values.","If validating multiple values, call the function once per value in a loop."],"exampleFix":"// before\nvar ok = LuhnCheck(cardNumber, true);\n// after\nvar ok = LuhnCheck(cardNumber);","handlingStrategy":"type-guard","validationCode":"// JS guard before calling\nif (cardNumber === undefined || cardNumber === null) return false;\nvar ok = LuhnCheck(String(cardNumber));","typeGuard":"function safeLuhnCheck(v) {\n  if (v === null || v === undefined) return false;\n  return LuhnCheck(String(v));\n}","tryCatchPattern":"try { var ok = LuhnCheck(num); }\ncatch (e) { if (String(e).indexOf('requires 1 argument') >= 0) { /* fix arity */ } throw e; }","preventionTips":["Call with exactly one argument","Validate the variable exists before the call","Loop over multiple values instead of passing arrays/extra args","Test in the script editor before production runs"],"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"}