{"record":{"id":"d8371f488afe19b2","repo":"pentaho/pentaho-kettle","slug":"the-function-call-loadfilecontentrequires-1-ou-2-arguments","errorCode":null,"errorMessage":"The function call loadFileContentrequires 1 ou 2 arguments.","messagePattern":"The function call loadFileContentrequires 1 ou 2 arguments\\.","errorType":"exception","errorClass":"Rhino runtime error","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":2829,"sourceCode":"              return null;\n            } else if ( isUndefined( ArgList[0] ) ) {\n              return Context.getUndefinedValue();\n            }\n            String encoding = null;\n            if ( !isUndefined( ArgList[1] ) && !ArgList[1].equals( null ) ) {\n              encoding = Context.toString( ArgList[1] );\n            }\n            // Returns file content\n            oRC = new String( LoadFileInput.getFileBinaryContent( getBowl( actualObject ),\n                                                                  Context.toString( ArgList[0] ) ), encoding );\n          } catch ( Exception e ) {\n            throw Context\n              .reportRuntimeError( \"The function call loadFileContent throw an error : \" + e.toString() );\n          }\n          break;\n\n        default:\n          throw Context.reportRuntimeError( \"The function call loadFileContentrequires 1 ou 2 arguments.\" );\n      }\n\n    } catch ( Exception e ) {\n      throw Context.reportRuntimeError( e.toString() );\n    }\n    return oRC;\n  }\n\n  public static int getOcuranceString( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    int nr = 0;\n    if ( ArgList.length == 2 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return 0;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return (Integer) Context.getUndefinedValue();\n        }","sourceCodeStart":2811,"sourceCodeEnd":2847,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2811-L2847","documentation":"The JavaScript JS function loadFileContent(), registered by ScriptValuesAddedFunctions for the Modified Java Script Value step, was called with an argument count other than 1 or 2. Rhino's reportRuntimeError is used to abort the script execution with a human-readable message when the switch on ArgList length falls through to default.","triggerScenarios":"Calling loadFileContent() with zero arguments or three or more arguments from a JavaScript script in the Modified Java Script Value step.","commonSituations":"Typos in the script (e.g. forgetting the filename argument), copy-pasting an example that used a different signature, or dynamically building argument lists that end up empty.","solutions":["Pass exactly 1 argument (file path) or 2 arguments (file path, encoding) to loadFileContent.","Check the script in the Modified Java Script Value step dialog and fix the call site.","If the arguments are computed at runtime, log the argument array length before calling."],"exampleFix":"// before\nvar content = loadFileContent();\n// after\nvar content = loadFileContent('/tmp/data.txt', 'UTF-8');","handlingStrategy":"validation","validationCode":"// JS in the script step\nif (arguments.length !== 1 && arguments.length !== 2) {\n  throw new Error('loadFileContent requires 1 or 2 arguments');\n}\nvar content = loadFileContent(path, encoding);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always call loadFileContent with a path plus optional encoding.","Keep the function signature documented in the transformation's script comments.","Test scripts with sample rows before production runs."],"tags":["javascript","argument-count","kettle","rhino"],"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"}