pentaho/pentaho-kettle · error · KettleFileException
Row.ErrorWritingRow
Error message
Row.ErrorWritingRow
What it means
setEnvironmentVar requires exactly 2 arguments (property name and value). This is an argument-count guard in ScriptValuesAddedFunctions.java: when ArgList.length != 2, the function throws a Rhino runtime error instead of silently proceeding. It exists because the underlying System.setProperty call needs both a key and a value.
Solutions
- Supply both arguments: setEnvironmentVar('MY_KEY', 'value').
- If the value may be absent, default it explicitly before calling: var v = x === undefined ? '' : x.
- Count arguments before calling to confirm exactly two are passed.
Example fix
// before
setEnvironmentVar("MY_KEY");
// after
setEnvironmentVar("MY_KEY", "myValue"); Defensive patterns
Strategy: validation
Validate before calling
var args = [key, value];
if (args.length !== 2) throw new Error("setEnvironmentVar needs name and value"); Type guard
null
Try / catch
try {
setEnvironmentVar(key, value === undefined ? "" : value);
} catch (e) {
// log and continue with a safe default
} Prevention
- Always pass a value even when 'empty' - use ""
- Default undefined variables before the call
- Review call sites for dropped arguments after refactoring
When it happens
Trigger: Calling setEnvironmentVar() with 0, 1, or 3+ arguments from JavaScript code in the Script Values / Modified Java Script Value step, e.g. setEnvironmentVar('MY_KEY') forgetting the value.
Common situations: Copy-pasted snippets where the second argument was dropped; dynamic argument construction where an optional value was undefined and removed; migrating scripts from other engines that tolerate one-argument calls.
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
- Row.EndOfFileReached
- Please provide a valid date to the function call date2str.
- Row.EndOfFileReadingRow
- Row.RowError
- The function call copyFile is not valid.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/328b0eeaf0f692ce.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/compatibility/Row.java:461
// Write all values in the row
for ( int i = 0; i < size(); i++ ) {
getValue( i ).writeObj( dos );
}
}
/**
* Write the content of the row to a DataOutputStream.
*
* @param dos
* The DataOutputStream to write to
* @throws KettleFileException
* if an error occurs.
*/
public void write( DataOutputStream dos ) throws KettleFileException {
try {
writeObj( dos );
} catch ( Exception e ) {
throw new KettleFileException( BaseMessages.getString( PKG, "Row.ErrorWritingRow" ), e );
}
}
private void readObj( DataInputStream dis ) throws IOException {
// First handle the number of fields in a row
int size = dis.readInt();
// get all values in the row
for ( int i = 0; i < size; i++ ) {
Value v = new Value();
v.readObj( dis );
addValue( v );
}
}
/**
* Read a row of Values from an input-stream.
*View on GitHub (pinned to f3058517a1)