pentaho/pentaho-kettle · error · KettleStepException

Field [ ] couldn't be found in the input stream!

Error message

Field [{fieldName}] couldn't be found in the input stream!

What it means

TextFileOutput validates that every field configured in the step's output field mapping exists in the incoming row stream by calling indexOfValue on the row metadata. If a configured field name is not present in the input stream, initFieldNumbers throws this KettleStepException before any rows are written. It protects the step from silently writing null or misaligned columns.

Solutions

  1. Open the TextFileOutput step, use 'Get Fields' to re-import the actual input fields, and fix or remove the missing field
  2. Check the field name spelling and case against the preview of the previous step's output
  3. Verify the upstream step still produces the field (preview the input rows)
  4. Rebuild the field mapping after any upstream schema change

Example fix

// before
fields[i].setName( "CusotmerId" ); // typo, not in stream
// after
fields[i].setName( "CustomerId" ); // matches input row metadata exactly
Defensive patterns

Strategy: validation

Validate before calling

RowMetaInterface inputRowMeta = transMeta.getPrevStepFields( stepName );
for ( TextFileField f : outputFields ) {
  if ( inputRowMeta.indexOfValue( f.getName() ) < 0 ) {
    throw new IllegalArgumentException( "Field not in stream: " + f.getName() );
  }
}

Try / catch

try {
  initFieldNumbers( outputRowMeta, outputFields );
} catch ( KettleStepException e ) {
  // list actual stream fields to aid diagnosis
  logError( e.getMessage() + " Available: " + String.join( ",", outputRowMeta.getFieldNames() ), e );
  setErrors( 1 );
  return false;
}

Prevention

When it happens

Trigger: processRow -> initFieldNumbers with an outputFields entry whose getName() has no match (indexOfValue < 0) in outputRowMeta: field renamed upstream, typo in field name, wrong field casing, or a removed/reordered upstream step no longer produces the field.

Common situations: Renaming a column in an upstream step without updating the text file output field list; copy-pasting a transformation between environments where upstream schemas differ; typo when manually editing field definitions; Kettle case-sensitive field matching ('Name' vs 'name').

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — 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/7b975d3632e93e3f. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/textfileoutput/TextFileOutput.java:82

      TextFileOutputMeta.fileCompressionTypeCodes[TextFileOutputMeta.FILE_COMPRESSION_TYPE_NONE];
  private static final boolean COMPATIBILITY_APPEND_NO_HEADER = "Y".equals(
          Const.NVL( System.getProperty( Const.KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER ), "N" ) );

  public TextFileOutputMeta meta;

  public TextFileOutputData data;

  public TextFileOutput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
      Trans trans ) {
    super( stepMeta, stepDataInterface, copyNr, transMeta, trans );
  }

  private void initFieldNumbers( RowMetaInterface outputRowMeta, TextFileField[] outputFields ) throws KettleException {
    data.fieldnrs = new int[outputFields.length];
    for ( int i = 0; i < outputFields.length; i++ ) {
      data.fieldnrs[i] = outputRowMeta.indexOfValue( outputFields[i].getName() );
      if ( data.fieldnrs[i] < 0 ) {
        throw new KettleStepException( "Field [" + outputFields[i].getName()
          + "] couldn't be found in the input stream!" );
      }
    }
  }

  public boolean isFileExists( String filename ) throws KettleException {
    try {
      return getFileObject( filename, getTransMeta() ).exists();
    } catch ( Exception e ) {
      throw new KettleException( "Error opening new file : " + e.toString() );
    }
  }

  private CompressionProvider getCompressionProvider() throws KettleException {
    String compressionType = Const.NVL( meta.getFileCompression(), FILE_COMPRESSION_TYPE_NONE );

    CompressionProvider compressionProvider = CompressionProviderFactory.getInstance().getCompressionProviderByName( compressionType );

View on GitHub (pinned to f3058517a1)