{"record":{"id":"bda4aa7edd9fd8bc","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getenvironmentvar-requires-1-argument-bda4aa","errorCode":null,"errorMessage":"The function call getEnvironmentVar requires 1 argument.","messagePattern":"The function call getEnvironmentVar requires 1 argument\\.","errorType":"exception","errorClass":"RhinoRuntimeError","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":1629,"sourceCode":"          Object scmo = actualObject.get( \"_step_\", actualObject );\n          Object scmO = Context.jsToJava( scmo, StepInterface.class );\n\n          if ( scmO instanceof StepInterface ) {\n            StepInterface scm = (StepInterface) Context.jsToJava( scmO, StepInterface.class );\n            sArg1 = Context.toString( ArgList[0] );\n            sRC = scm.getVariable( sArg1, \"\" );\n          } else {\n            // running in test mode, return \"\"\n            sRC = \"\";\n          }\n\n        }\n\n      } catch ( Exception e ) {\n        sRC = \"\";\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call getEnvironmentVar requires 1 argument.\" );\n    }\n    return sRC;\n  }\n\n  public static String trim( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    String sRC = \"\";\n    if ( ArgList.length == 1 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return null;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return (String) Context.getUndefinedValue();\n        }\n        sRC = Context.toString( ArgList[0] );\n        sRC = Const.trim( sRC );\n      } catch ( Exception e ) {\n        throw Context.reportRuntimeError( \"The function call trim is not valid : \" + e.getMessage() );","sourceCodeStart":1611,"sourceCodeEnd":1647,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L1611-L1647","documentation":"Argument-count guard in ScriptValuesAddedFunctions.getEnvironmentVar, which reads a variable (step/kettle environment variable) by name and returns \"\" if it is unset or on any lookup failure. It fires when the script calls getEnvironmentVar with an argument count other than exactly 1; Rhino raises a runtime error instead of attempting the lookup. Fix by calling getEnvironmentVar with exactly one string argument naming the variable.","triggerScenarios":"Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1629 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call getEnvironmentVar(name) with exactly one argument","Use setEnvironmentVar first if the variable may not exist"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}