pentaho/pentaho-kettle · error · Rhino runtime error
Please provide a filename to the function call…
Error message
Please provide a filename to the function call loadFileContent.
What it means
loadFileContent reads a file's contents into a JS variable in the Modified Java Script Value step. The library throws this Rhino runtime error when the function is called with zero arguments, because a filename is mandatory to know which file to read.
Solutions
- Pass the file path as the first argument: loadFileContent('/path/to/file')
- Ensure the filename variable is non-empty before calling (guard with an if)
- Check that the field feeding the argument is populated in the incoming rows
- Prefer Kettle's Text File Input step for bulk file reads instead of per-row JS
Example fix
// before var content = loadFileContent(); // after var content = loadFileContent(filenameField);
Defensive patterns
Strategy: validation
Validate before calling
if (typeof filenameField === 'string' && filenameField.length > 0) { var content = loadFileContent(filenameField); } else { var content = null; } Type guard
function hasFilename(v){ return typeof v === 'string' && v.trim().length > 0; } Try / catch
try { var content = loadFileContent(filenameField); } catch (e) { throw new Error('loadFileContent needs a filename: ' + e.message); } Prevention
- Always pass a non-empty filename as the first argument
- Validate the incoming field is populated before calling
- Use dedicated input steps for heavy file reading rather than per-row JS
- Handle null/undefined filename rows gracefully instead of letting the call collapse to zero args
When it happens
Trigger: loadFileContent() with an empty argument list — the switch case 0 immediately throws Context.reportRuntimeError; also occurs when the filename variable passed is dropped so the array is empty.
Common situations: Field variable undefined at runtime so the call collapses to no arguments; users forgetting to pass the path expecting a file-picker dialog; scripts copied without the filename argument.
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
- Could not convert to the given local format.
- Error opening file [" + data.filename + "]!
- Error while reading file \"
- file to move [ + ArgList[0] + ] can not be found!
- Please provide a valid Char to the fillString
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/7e431f3310713f02.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:2792
public static String initCap( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
return Const.initCap( Context.toString( ArgList[0] ) );
} else {
throw Context.reportRuntimeError( "The function call initCap requires 1 argument." );
}
}
public static Object loadFileContent( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
Object oRC = new Object();
try {
switch ( ArgList.length ) {
case 0:
throw Context.reportRuntimeError( "Please provide a filename to the function call loadFileContent." );
case 1:
try {
if ( isNull( ArgList ) ) {
return null;
} else if ( isUndefined( ArgList ) ) {
return Context.getUndefinedValue();
}
// Returns file content
oRC = new String( LoadFileInput.getFileBinaryContent( getBowl( actualObject ),
Context.toString( ArgList[0] ) ) );
} catch ( Exception e ) {
throw Context
.reportRuntimeError( "The function call loadFileContent throw an error : " + e.toString() );
}
break;
case 2:
try {
if ( ArgList[0].equals( null ) ) {View on GitHub (pinned to f3058517a1)