{"record":{"id":"a0ea1b8ea3709ea9","repo":"pentaho/pentaho-kettle","slug":"the-function-call-isnum-requires-1-argument-a0ea1b","errorCode":null,"errorMessage":"The function call isNum requires 1 argument.","messagePattern":"The function call isNum requires 1 argument\\.","errorType":"exception","errorClass":"RhinoRuntimeError","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":1489,"sourceCode":"\n    if ( ArgList.length == 1 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return null;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return Context.getUndefinedValue();\n        }\n        double sArg1 = Context.toNumber( ArgList[0] );\n        if ( Double.isNaN( sArg1 ) ) {\n          return Boolean.FALSE;\n        } else {\n          return Boolean.TRUE;\n        }\n      } catch ( Exception e ) {\n        return Boolean.FALSE;\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call isNum requires 1 argument.\" );\n    }\n  }\n\n  public static Object isDate( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n\n    if ( ArgList.length == 1 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return null;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return Context.getUndefinedValue();\n        }\n        /* java.util.Date d = (java.util.Date) */Context.jsToJava( ArgList[0], java.util.Date.class );\n        return Boolean.TRUE;\n      } catch ( Exception e ) {\n        return Boolean.FALSE;\n      }","sourceCodeStart":1471,"sourceCodeEnd":1507,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L1471-L1507","documentation":"The isNum JavaScript function tests whether a single value converts to a number; it returns Boolean.FALSE (rather than throwing) if the conversion fails, but if called with an argument count other than exactly 1 it throws this error via Context.reportRuntimeError. It is purely an arity check in the function's else branch.","triggerScenarios":"isNum() with no argument; isNum('1', '2'); isNum applied to multiple fields at once as if it accepted varargs.","commonSituations":"Treating isNum like a spread validator for a row of fields; a refactor that removed wrapping multiple values into an array before testing.","solutions":["Call isNum with exactly one argument","To test several values, call isNum once per value","Test the joined/converted value if you need a composite check","Wrap multi-field checks in a small helper function in the script"],"exampleFix":"// before\nvar ok = isNum(fieldA, fieldB); // throws\n// after\nvar ok = isNum(fieldA) && isNum(fieldB);","handlingStrategy":"type-guard","validationCode":"function isNumSafe(v) {\n  return v !== null && v !== undefined && isNum(v);\n}","typeGuard":"function exactlyOneArg(args) { return args.length === 1; }","tryCatchPattern":"try {\n  var ok = isNum(field);\n} catch (e) {\n  if (e.message.indexOf('isNum requires 1 argument') >= 0) {\n    // wrong arity — check the call site\n  }\n}","preventionTips":["Call isNum once per field, never with multiple fields","Remember non-numeric values return FALSE silently — handle the FALSE branch","Use isNum as a gate before str2num in the same script","Keep validation helpers single-purpose in script steps"],"tags":["javascript","argument-count","pentaho","validation"],"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"}