pentaho/pentaho-kettle · error · KettleException

CsvInput.Exception.FilenameFieldNotFound (with…

Error message

CsvInput.Exception.FilenameFieldNotFound (with filenameField)

What it means

CsvInput reads a list of filenames from rows arriving on the input stream when 'File passed via field' is enabled. It looks up the configured filename field in the incoming row metadata; if the field does not exist in the input row layout, indexOfValue returns -1 and this KettleException is thrown. It means the step's filenameField setting does not match any column actually produced by the previous step.

Solutions

  1. Open the CsvInput step dialog and set 'The filename field' (FilenameField) to the exact name of the field containing filenames in the incoming rows.
  2. Verify the previous step actually emits that field: preview the previous step and check the field names (case-sensitive).
  3. If the field name contains an environment variable, confirm the variable is set so it resolves to the correct field name.

Example fix

// before (dialog config)
filenameField = "filename"
// after (field renamed upstream to filepath)
filenameField = "filepath"
Defensive patterns

Strategy: validation

Validate before calling

// before running, verify the incoming row layout contains the field
String[] fields = transMeta.getPrevStepFields(stepMeta).getFieldNames();
if (java.util.Arrays.asList(fields).indexOf(envSubstitute(filenameField)) < 0) {
  throw new IllegalStateException("filenameField not in input rows: " + filenameField);
}

Try / catch

try { ... } catch (KettleException e) {
  logError("Filename field '" + filenameField + "' missing from input rows", e);
  setErrors(1);
}

Prevention

When it happens

Trigger: 'Accept filenames in previous step' is checked and the configured filenameField (after environment substitution) is not present in the incoming row's ValueMeta list, e.g. the field was renamed, removed, or the wrong field name was typed in the step dialog.

Common situations: Renaming or deleting the filename column in an upstream step (Text File Input, Get File Names) without updating CsvInput; environment variable substitution producing a different field name; wiring the wrong hop into CsvInput.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/csvinput/CsvInput.java:275

    }
  }

  private void getFilenamesFromPreviousSteps() throws KettleException {
    List<String> filenames = new ArrayList<>();
    boolean firstRow = true;
    int index = -1;
    Object[] row = getRow();
    while ( row != null ) {

      if ( firstRow ) {
        firstRow = false;

        // Get the filename field index...
        //
        String filenameField = environmentSubstitute( meta.getFilenameField() );
        index = getInputRowMeta().indexOfValue( filenameField );
        if ( index < 0 ) {
          throw new KettleException( BaseMessages.getString(
            PKG, "CsvInput.Exception.FilenameFieldNotFound", filenameField ) );
        }
      }

      String filename = getInputRowMeta().getString( row, index );
      filenames.add( filename ); // add it to the list...

      row = getRow(); // Grab another row...
    }

    data.filenames = filenames.toArray( new String[ filenames.size() ] );

    logBasic( BaseMessages.getString( PKG, "CsvInput.Log.ReadingFromNrFiles", Integer
      .toString( data.filenames.length ) ) );
  }

  @Override
  public void dispose( StepMetaInterface smi, StepDataInterface sdi ) {

View on GitHub (pinned to f3058517a1)