{"record":{"id":"60f4900ccd304997","repo":"pentaho/pentaho-kettle","slug":"the-function-call-ceil-requires-1-argument","errorCode":null,"errorMessage":"The function call ceil requires 1 argument.","messagePattern":"The function call ceil 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":394,"sourceCode":"    }\n  }\n\n  public static Object ceil( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\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 undefinedValue;\n        } else {\n          return new Double( Math.ceil( (Double) ArgList[0] ) );\n        }\n      } catch ( Exception e ) {\n        return null;\n      }\n    } else {\n      throw new RuntimeException( \"The function call ceil requires 1 argument.\" );\n    }\n  }\n\n  public static Object floor( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\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 undefinedValue;\n        } else {\n          return new Double( Math.floor( (Double) ArgList[0] ) );\n        }\n      } catch ( Exception e ) {\n        return null;\n        // throw new RuntimeException(e.toString());\n      }","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L376-L412","documentation":"Arity guard in ScriptAddedFunctions.ceil: the script call supplied an ArgList whose length is not 1. With exactly one numeric argument the function returns Math.ceil as a Double (null/undefined input maps to NaN); any other argument count raises this RuntimeException to the script.","triggerScenarios":"Calling ceil() with zero arguments or ceil(x, precision) with two arguments in a Script step.","commonSituations":"Expecting a precision parameter like some spreadsheet CEIL functions; typos in generated scripts.","solutions":["Call ceil with exactly one numeric argument","Implement rounding-to-precision manually in JS if needed (Math.ceil(x*p)/p)","Guard that the argument is a Number before calling"],"exampleFix":"// before\nvar v = ceil(x, 2);\n// after\nvar v = ceil(x * 100) / 100;","handlingStrategy":"validation","validationCode":"// JS in Script step\nif (arguments.length !== 1 || typeof arguments[0] !== 'number') {\n  throw new Error('ceil expects exactly one numeric argument');\n}\nvar v = ceil(x);","typeGuard":"// JS\nfunction isSingleNumber(args) {\n  return args.length === 1 && typeof args[0] === 'number' && !isNaN(args[0]);\n}","tryCatchPattern":"try {\n  var v = ceil(x);\n  if (v === null) { /* non-numeric input case */ }\n} catch (e) {\n  Logger.logError('ceil failed: ' + e.message);\n  v = null;\n}","preventionTips":["Implement precision rounding manually; ceil has no second argument","Ensure numeric input to avoid silent null returns","Check function help for arity before porting spreadsheet formulas"],"tags":["kettle","javascript","arity","math"],"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"}