pentaho/pentaho-kettle · error · KettleException

Unable to find field [

Error message

Unable to find field [

What it means

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).

Solutions

  1. Re-select the field in the Set Variables dialog using 'Get Fields' so it matches the actual incoming row.
  2. Preview the previous step to see the exact field names and fix spelling/case.
  3. Remove or reconfigure any upstream Select values/Filter steps that drop the field.
  4. 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.

Example fix

// before
meta.setFieldName(new String[] { "envrionment" });
// after
meta.setFieldName(new String[] { "environment" }); // matches upstream field
Defensive patterns

Strategy: validation

Validate before calling

RowMetaInterface upstream = transMeta.getPrevStepFields(setVarStepMeta);
for (String f : meta.getFieldName()) {
  if (upstream.indexOfValue(f) < 0) {
    throw new IllegalStateException("Set Variables field missing upstream: " + f);
  }
}

Type guard

if (outputMeta.indexOfValue(fieldName) < 0) { return null; }

Try / catch

try {
  trans.execute(null);
} catch (KettleException e) {
  log.error("Set Variables field lookup failed: {}", e.getMessage());
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/d481d852f4a77073. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/setvariable/SetVariable.java:101

      putRow( data.outputMeta, rowData );
      return true;
    }

    throw new KettleStepException( BaseMessages.getString(
      PKG, "SetVariable.RuntimeError.MoreThanOneRowReceived.SETVARIABLE0007" ) );
  }

  private void setValue( Object[] rowData, int i, boolean usedefault ) throws KettleException {
    // Set the appropriate environment variable
    //
    String value = null;
    if ( usedefault ) {
      value = environmentSubstitute( meta.getDefaultValue()[i] );
    } else {
      int index = data.outputMeta.indexOfValue( meta.getFieldName()[i] );
      if ( index < 0 ) {
        throw new KettleException( "Unable to find field [" + meta.getFieldName()[i] + "] in input row" );
      }
      ValueMetaInterface valueMeta = data.outputMeta.getValueMeta( index );
      Object valueData = rowData[index];

      // Get variable value
      //
      if ( meta.isUsingFormatting() ) {
        value = valueMeta.getString( valueData );
      } else {
        value = valueMeta.getCompatibleString( valueData );
      }

    }

    if ( value == null ) {
      value = "";
    }

View on GitHub (pinned to f3058517a1)