{"record":{"id":"3db68c85267215e9","repo":"pentaho/pentaho-kettle","slug":"the-function-call-floor-requires-1-argument","errorCode":null,"errorMessage":"The function call floor requires 1 argument.","messagePattern":"The function call floor 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":414,"sourceCode":"  }\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      }\n    } else {\n      throw new RuntimeException( \"The function call floor requires 1 argument.\" );\n    }\n  }\n\n  public static Object getDayNumber( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n    if ( ArgList.length == 2 ) {\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          java.util.Date dIn = (java.util.Date) ArgList[0];\n          String strType = ( (String) ArgList[1] ).toLowerCase();\n          Calendar startDate = Calendar.getInstance();\n          startDate.setTime( dIn );\n          if ( strType.equals( \"y\" ) ) {\n            return new Double( startDate.get( Calendar.DAY_OF_YEAR ) );","sourceCodeStart":396,"sourceCodeEnd":432,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L396-L432","documentation":"ScriptAddedFunctions implements the JavaScript (Rhino/Nashorn) utility functions available in the Script step (e.g. floor()). When floor() is invoked from script code, it requires exactly one argument (the value to round down). If ArgList.length != 1, the function throws this RuntimeException instead of silently returning a wrong result.","triggerScenarios":"Calling floor() in a Script step with zero arguments or more than one argument, e.g. floor() or floor(a, b).","commonSituations":"Copy-pasted script code edited by hand; calling floor with a comma-separated list thinking it takes multiple values; extra context arguments passed by mistake.","solutions":["Pass exactly one argument: floor(value).","Check the script for accidental extra arguments or a missing argument after refactor.","If you need to round several values, call floor once per value."],"exampleFix":"// before\nvar x = floor(val, 0);\n// after\nvar x = floor(val);","handlingStrategy":"validation","validationCode":"if (typeof val === 'number') { var x = floor(val); }","typeGuard":"function isNum(v) { return typeof v === 'number' && !isNaN(v); }","tryCatchPattern":"try { var x = floor(val); } catch (e) { if (/floor requires 1 argument/.test(String(e))) { /* fix call site */ } else { throw e; } }","preventionTips":["Always call floor with exactly one numeric argument.","Review script changes for altered function signatures.","Keep a reference of Script step helper signatures handy."],"tags":["javascript","script-step","argument-count"],"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"}