{"record":{"id":"328b0eeaf0f692ce","repo":"pentaho/pentaho-kettle","slug":"row-errorwritingrow","errorCode":null,"errorMessage":"Row.ErrorWritingRow","messagePattern":"Row\\.ErrorWritingRow","errorType":"exception","errorClass":"KettleFileException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/compatibility/Row.java","lineNumber":461,"sourceCode":"    // Write all values in the row\n    for ( int i = 0; i < size(); i++ ) {\n      getValue( i ).writeObj( dos );\n    }\n  }\n\n  /**\n   * Write the content of the row to a DataOutputStream.\n   *\n   * @param dos\n   *          The DataOutputStream to write to\n   * @throws KettleFileException\n   *           if an error occurs.\n   */\n  public void write( DataOutputStream dos ) throws KettleFileException {\n    try {\n      writeObj( dos );\n    } catch ( Exception e ) {\n      throw new KettleFileException( BaseMessages.getString( PKG, \"Row.ErrorWritingRow\" ), e );\n    }\n  }\n\n  private void readObj( DataInputStream dis ) throws IOException {\n    // First handle the number of fields in a row\n    int size = dis.readInt();\n\n    // get all values in the row\n    for ( int i = 0; i < size; i++ ) {\n      Value v = new Value();\n      v.readObj( dis );\n      addValue( v );\n    }\n  }\n\n  /**\n   * Read a row of Values from an input-stream.\n   *","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/compatibility/Row.java#L443-L479","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nsetEnvironmentVar(\"MY_KEY\");\n// after\nsetEnvironmentVar(\"MY_KEY\", \"myValue\");","handlingStrategy":"validation","validationCode":"var args = [key, value];\nif (args.length !== 2) throw new Error(\"setEnvironmentVar needs name and value\");","typeGuard":"null","tryCatchPattern":"try {\n  setEnvironmentVar(key, value === undefined ? \"\" : value);\n} catch (e) {\n  // log and continue with a safe default\n}","preventionTips":["Always pass a value even when 'empty' - use \"\"","Default undefined variables before the call","Review call sites for dropped arguments after refactoring"],"tags":["javascript","argument-count","scripting","environment"],"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"}