{"record":{"id":"e8ab00e27ecafd15","repo":"pentaho/pentaho-kettle","slug":"the-function-call-abs-requires-1-argument-e8ab00","errorCode":null,"errorMessage":"The function call abs requires 1 argument.","messagePattern":"The function call abs 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":393,"sourceCode":"  }\n\n  public static Object abs( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n\n    if ( ArgList.length == 1 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return new Double( Double.NaN );\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return Context.getUndefinedValue();\n        } else {\n          return new Double( Math.abs( Context.toNumber( ArgList[0] ) ) );\n        }\n      } catch ( Exception e ) {\n        return null;\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call abs requires 1 argument.\" );\n    }\n  }\n\n  public static Object ceil( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return Double.NaN;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return Context.getUndefinedValue();\n        } else {\n          return Math.ceil( Context.toNumber( ArgList[ 0 ] ) );\n        }\n      } catch ( Exception e ) {\n        return null;\n      }\n    } else {","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L375-L411","documentation":"The abs() helper registered for the ScriptValuesMod step wraps Math.abs but requires exactly 1 numeric argument; calling it with zero arguments (or any count other than 1) throws this Rhino runtime error.","triggerScenarios":"abs() with no arguments, or abs(a, b) with two, in a Modified Java Script Value step.","commonSituations":"Migrating from another scripting library where abs accepted a list or array; forgetting the argument when testing; passing an array expecting element-wise results.","solutions":["Call abs with exactly one numeric argument: abs(myNumber).","Apply it per element if you have an array, not on the array itself.","Ensure the argument expression yields a number (Context.toNumber is applied inside)."],"exampleFix":"// before\nvar a = abs();\n// after\nvar a = abs(myValue);","handlingStrategy":"validation","validationCode":"var n = +(myValue);\nif (isNaN(n)) n = 0;\nvar a = abs(n);","typeGuard":"function isNumber(v){ return typeof v === 'number' && !isNaN(v); }","tryCatchPattern":null,"preventionTips":["Always supply one numeric argument.","Coerce strings to numbers with +value before math helpers.","Handle arrays element-wise rather than passing the array."],"tags":["javascript","argument-count","math","pdi-kettle"],"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"}