pentaho/pentaho-kettle · error · KettleException

SortRowsMeta.CheckResult.StepFieldNotInInputStream

SortRowsMeta.CheckResult.StepFieldNotInInputStream

Error message

SortRowsMeta.CheckResult.StepFieldNotInInputStream

What it means

During SortRows.processRow() initialization, each configured sort field is looked up by name in the incoming row metadata. If indexOfValue() returns -1 the step cannot sort, so it throws a KettleException using the SortRowsMeta.CheckResult.StepFieldNotInInputStream message, naming the missing field and step.

Solutions

  1. Open the Sort rows step and re-select field names from the current upstream field list (delete and re-add stale entries).
  2. Check exact case and whitespace of the field name vs upstream output.
  3. Use 'Get Fields' in the step dialog after the upstream step is finalized.
  4. Preview the input row (right-click step > Preview) to confirm which fields actually arrive.
  5. Fix upstream steps that conditionally drop or rename the field.

Example fix

// before
sortField[0] = "CUSTOMER ID"; // upstream field is 'CUSTOMER_ID'
// after
sortField[0] = "CUSTOMER_ID";
Defensive patterns

Strategy: validation

Validate before calling

for (String f : meta.getFieldName()) {
  if (inputRowMeta.indexOfValue(f) < 0) {
    throw new IllegalArgumentException("Sort field not in stream: " + f);
  }
}

Try / catch

try { trans.execute(new String[0]); } catch (KettleException e) {
  if (e.getMessage().contains("field") && e.getMessage().contains("row")) {
    logError("Sort field missing from input: " + e.getMessage());
  }
}

Prevention

When it happens

Trigger: A field name configured in the Sort rows step does not exist in the row arriving at runtime — typically because an upstream step was changed/removed, field names are case-mismatched, or the hop delivering the row differs from the design-time preview.

Common situations: Renaming a column upstream (e.g., in Select values) without updating Sort rows; streams where fields appear only conditionally; whitespace differences in the field name; switching the primary input hop.

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/8707d3a7256e432f. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/sort/SortRows.java:420

            return false;
          }
        }
      }

      String[] fieldNames = meta.getFieldName();
      data.fieldnrs = new int[fieldNames.length];
      List<Integer> toConvert = new ArrayList<Integer>();

      // Metadata
      data.outputRowMeta = inputRowMeta.clone();
      meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,
        metaStore );
      data.comparator = new RowTemapFileComparator( data.outputRowMeta, data.fieldnrs );

      for ( int i = 0; i < fieldNames.length; i++ ) {
        data.fieldnrs[i] = inputRowMeta.indexOfValue( fieldNames[i] );
        if ( data.fieldnrs[i] < 0 ) {
          throw new KettleException( BaseMessages.getString( PKG, "SortRowsMeta.CheckResult.StepFieldNotInInputStream",
              meta.getFieldName()[i], getStepname() ) );
        }
        // do we need binary conversion for this type?
        if ( inputRowMeta.getValueMeta( data.fieldnrs[i] ).isStorageBinaryString() ) {
          toConvert.add( data.fieldnrs[i] );
        }
      }
      data.convertKeysToNative = toConvert.isEmpty() ? null : new int[toConvert.size()];
      int i = 0;
      for ( Integer in : toConvert ) {
        data.convertKeysToNative[i] = in;
        i++;
      }
      data.rowComparator = new RowObjectArrayComparator( data.outputRowMeta, data.fieldnrs );
    } // end if first

    // it is not first row and it is null
    if ( r == null ) {

View on GitHub (pinned to f3058517a1)