pentaho/pentaho-kettle · error · Rhino runtime error
The function call loadFileContentrequires 1 ou 2 arguments.
Error message
The function call loadFileContentrequires 1 ou 2 arguments.
What it means
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.
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.
Example fix
// before
var content = loadFileContent();
// after
var content = loadFileContent('/tmp/data.txt', 'UTF-8'); Defensive patterns
Strategy: validation
Validate before calling
// JS in the script step
if (arguments.length !== 1 && arguments.length !== 2) {
throw new Error('loadFileContent requires 1 or 2 arguments');
}
var content = loadFileContent(path, encoding); Prevention
- 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.
When it happens
Trigger: Calling loadFileContent() with zero arguments or three or more arguments from a JavaScript script in the Modified Java Script Value step.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Script.Log.CouldNotAddDefaultConstants
- The function call dateAdd requires 3 arguments.
- The function call dateDiff requires 3 arguments.
- The function call fillString requires 2 arguments.
- The function call fireToDB requires 2 arguments.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/d8371f488afe19b2.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:2829
return null;
} else if ( isUndefined( ArgList[0] ) ) {
return Context.getUndefinedValue();
}
String encoding = null;
if ( !isUndefined( ArgList[1] ) && !ArgList[1].equals( null ) ) {
encoding = Context.toString( ArgList[1] );
}
// Returns file content
oRC = new String( LoadFileInput.getFileBinaryContent( getBowl( actualObject ),
Context.toString( ArgList[0] ) ), encoding );
} catch ( Exception e ) {
throw Context
.reportRuntimeError( "The function call loadFileContent throw an error : " + e.toString() );
}
break;
default:
throw Context.reportRuntimeError( "The function call loadFileContentrequires 1 ou 2 arguments." );
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
return oRC;
}
public static int getOcuranceString( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
int nr = 0;
if ( ArgList.length == 2 ) {
try {
if ( isNull( ArgList[0] ) ) {
return 0;
} else if ( isUndefined( ArgList[0] ) ) {
return (Integer) Context.getUndefinedValue();
}View on GitHub (pinned to f3058517a1)