pentaho/pentaho-kettle · error · KettleStepException

ScriptValuesMetaMod.Exception.FieldToReplaceNotFound

Error message

ScriptValuesMetaMod.Exception.FieldToReplaceNotFound

What it means

During getFields() row-metadata calculation, the step looks up each configured fieldname[i] in the input row. When the field is absent AND no rename[i] is configured, it throws KettleStepException 'FieldToReplaceNotFound' naming the field, because there is no field to apply the script's replace/type change to.

Solutions

  1. Add the missing field upstream (e.g. via a Select values / Get variables step) or fix the field name in the Script step config.
  2. Specify the correct 'rename' field in the step settings if the field has a new name.
  3. Use 'Show input fields' in Spoon to verify the actual incoming field names.
  4. Reorder steps so the field exists before the Script step.

Example fix

// before (step config)
fieldName: "amount_old"
// after
fieldName: "amount"  // matches actual upstream field
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check in Spoon or via Kettle API before running the step
RowMetaInterface input = ...;
for (String field : configuredFieldNames) {
  if (input.indexOfValue(field) < 0) throw new IllegalStateException("Missing field: " + field);
}

Try / catch

try { step.getFields(rowMeta, origin, info, target, meta, variables); } catch (KettleStepException e) {
  // e.getMessage() names the missing field; repair upstream or config
}

Prevention

When it happens

Trigger: The step is configured to modify/replace field X, but the incoming row stream has no field named X and no rename field is specified.

Common situations: Upstream step renamed or removed the field, the transformation was reordered so the field isn't yet defined, or a typo in the field name in the step config.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesMetaMod.java:406

    optimizationLevel = OPTIMIZATION_LEVEL_DEFAULT;
  }

  @Override
  public void getFields( Bowl bowl, RowMetaInterface row, String originStepname, RowMetaInterface[] info, StepMeta nextStep,
    VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
    try {
      for ( int i = 0; i < fieldname.length; i++ ) {
        if ( !Utils.isEmpty( fieldname[i] ) ) {
          int valueIndex = -1;
          ValueMetaInterface v;
          if ( replace[i] ) {
            valueIndex = row.indexOfValue( fieldname[i] );
            if ( valueIndex < 0 ) {
              // The field was not found using the "name" field
              if ( Utils.isEmpty( rename[i] ) ) {
                // There is no "rename" field to try; Therefore we cannot find the
                // field to replace
                throw new KettleStepException( BaseMessages.getString(
                  PKG, "ScriptValuesMetaMod.Exception.FieldToReplaceNotFound", fieldname[i] ) );
              } else {
                // Lookup the field to replace using the "rename" field
                valueIndex = row.indexOfValue( rename[i] );
                if ( valueIndex < 0 ) {
                  // The field was not found using the "rename" field"; Therefore
                  // we cannot find the field to replace
                  //
                  throw new KettleStepException( BaseMessages.getString(
                    PKG, "ScriptValuesMetaMod.Exception.FieldToReplaceNotFound", rename[i] ) );
                }
              }
            }

            // Change the data type to match what's specified...
            //
            ValueMetaInterface source = row.getValueMeta( valueIndex );
            v = ValueMetaFactory.cloneValueMeta( source, type[i] );

View on GitHub (pinned to f3058517a1)