{"record":{"id":"d481d852f4a77073","repo":"pentaho/pentaho-kettle","slug":"unable-to-find-field","errorCode":null,"errorMessage":"Unable to find field [","messagePattern":"Unable to find field \\[","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/setvariable/SetVariable.java","lineNumber":101,"sourceCode":"\n      putRow( data.outputMeta, rowData );\n      return true;\n    }\n\n    throw new KettleStepException( BaseMessages.getString(\n      PKG, \"SetVariable.RuntimeError.MoreThanOneRowReceived.SETVARIABLE0007\" ) );\n  }\n\n  private void setValue( Object[] rowData, int i, boolean usedefault ) throws KettleException {\n    // Set the appropriate environment variable\n    //\n    String value = null;\n    if ( usedefault ) {\n      value = environmentSubstitute( meta.getDefaultValue()[i] );\n    } else {\n      int index = data.outputMeta.indexOfValue( meta.getFieldName()[i] );\n      if ( index < 0 ) {\n        throw new KettleException( \"Unable to find field [\" + meta.getFieldName()[i] + \"] in input row\" );\n      }\n      ValueMetaInterface valueMeta = data.outputMeta.getValueMeta( index );\n      Object valueData = rowData[index];\n\n      // Get variable value\n      //\n      if ( meta.isUsingFormatting() ) {\n        value = valueMeta.getString( valueData );\n      } else {\n        value = valueMeta.getCompatibleString( valueData );\n      }\n\n    }\n\n    if ( value == null ) {\n      value = \"\";\n    }\n","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/setvariable/SetVariable.java#L83-L119","documentation":"SetVariable.setValue, called from processRow when a row is available, looks up the configured field name in the row metadata via data.outputMeta.indexOfValue. A negative index means the field configured in the step does not exist in the input row, so no value can be read for the variable, and a plain KettleException is thrown (this one is a hardcoded literal, not a localized message).","triggerScenarios":"setValue: int index = data.outputMeta.indexOfValue(meta.getFieldName()[i]); if (index < 0) throw. Triggered when the 'Field name' configured in the Set Variables step is absent from the single input row (typo, renamed/removed upstream field, variable-resolved name that doesn't match).","commonSituations":"Upstream step's output changed between editing and running the transformation; the field name was typed manually with a typo; a Select values step earlier removed the field; running the transformation on another server where a plugin or conditional branch no longer emits the field.","solutions":["Re-select the field in the Set Variables dialog using 'Get Fields' so it matches the actual incoming row.","Preview the previous step to see the exact field names and fix spelling/case.","Remove or reconfigure any upstream Select values/Filter steps that drop the field.","If the field is optional, use the step's 'Default value' option so the variable is set even when the field is missing — but note the field must still exist in the row metadata for this lookup."],"exampleFix":"// before\nmeta.setFieldName(new String[] { \"envrionment\" });\n// after\nmeta.setFieldName(new String[] { \"environment\" }); // matches upstream field","handlingStrategy":"validation","validationCode":"RowMetaInterface upstream = transMeta.getPrevStepFields(setVarStepMeta);\nfor (String f : meta.getFieldName()) {\n  if (upstream.indexOfValue(f) < 0) {\n    throw new IllegalStateException(\"Set Variables field missing upstream: \" + f);\n  }\n}","typeGuard":"if (outputMeta.indexOfValue(fieldName) < 0) { return null; }","tryCatchPattern":"try {\n  trans.execute(null);\n} catch (KettleException e) {\n  log.error(\"Set Variables field lookup failed: {}\", e.getMessage());\n}","preventionTips":["Use 'Get Fields' in the Set Variables dialog, never free-typed names","Re-check the step after adding/removing upstream Select values steps","Preview the single input row before deploying","Test transformations on target servers where upstream metadata may differ"],"tags":["kettle","set-variables","field-not-found","configuration"],"backgroundTag":"field-not-found","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"}