pentaho/pentaho-kettle · error · RuntimeException
The function call setEnvironmentVar requires 2 arguments.
Error message
The function call setEnvironmentVar requires 2 arguments.
What it means
Arity guard for setEnvironmentVar in the script step: the function was invoked without exactly two arguments (name, value). Any count other than 2 falls into the else-branch and throws, because System.setProperty needs exactly one key and one value.
Solutions
- Call setEnvironmentVar(name, value) with exactly two String arguments.
- Split multiple variables into separate calls.
- Coerce values with String(...) to avoid the companion e.toString() error.
Example fix
// before
setEnvironmentVar('MY_VAR'); // throws
// after
setEnvironmentVar('MY_VAR', 'myValue'); Defensive patterns
Strategy: validation
Validate before calling
function safeSetEnv(name, value) {
if (arguments.length !== 2) throw new Error('setEnvironmentVar requires exactly 2 arguments');
setEnvironmentVar(name, value);
} Try / catch
try {
setEnvironmentVar(name, value);
} catch (e) {
if (String(e.message).indexOf('requires 2 arguments') >= 0) {
// fix the call site arity
}
} Prevention
- Always pass exactly two arguments: name and value.
- Set each variable in its own call.
- Fix arity errors at the call site rather than catching and swallowing.
When it happens
Trigger: Calling setEnvironmentVar(name) with one argument, or with three or more arguments, in a JavaScript transformation step.
Common situations: Forgetting the value argument, attempting to set several variables in one call, refactoring typos.
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
- The function call decode requires more than 1 argument.
- The function call isDate requires 1 argument.
- The function call isNum requires 1 argument.
- The function call replace is not valid (wrong number of…
- The function call str2num requires 1, 2, or 3 arguments.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/e7069e2f8820a9ad.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:1555
return "";
}
// Setting EnvironmentVar
public static void setEnvironmentVar( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
String sArg1 = "";
String sArg2 = "";
if ( ArgList.length == 2 ) {
try {
sArg1 = (String) ArgList[0];
sArg2 = (String) ArgList[1];
System.setProperty( sArg1, sArg2 );
} catch ( Exception e ) {
throw new RuntimeException( e.toString() );
}
} else {
throw new RuntimeException( "The function call setEnvironmentVar requires 2 arguments." );
}
}
// Returning EnvironmentVar
public static String getEnvironmentVar( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
String sRC = "";
if ( ArgList.length == 1 ) {
try {
String sArg1 = (String) ArgList[0];
sRC = System.getProperty( sArg1, "" );
} catch ( Exception e ) {
sRC = "";
}
} else {
throw new RuntimeException( "The function call getEnvironmentVar requires 1 argument." );
}
return sRC;View on GitHub (pinned to f3058517a1)