pentaho/pentaho-kettle · error · KettleException

ProcessFiles.Exception.CouldnotFindField

Error message

ProcessFiles.Exception.CouldnotFindField

What it means

KettleException thrown by ProcessFiles.processRow when the configured source filename field cannot be found in the incoming row's layout. getInputRowMeta().indexOfValue(field) returns -1, meaning the field named in the step settings does not exist in the stream at runtime. A parameterized message includes the missing field name.

Solutions

  1. Ensure the upstream step actually emits the configured field name (check with 'Preview' or a 'Field existence' check).
  2. Correct the 'Source filename fieldname' setting to match the exact field name in the stream.
  3. Add/repair the upstream step (e.g., Text File Input, Select Values) that produces the filename field.

Example fix

// before: settings say 'filename' but stream has 'filepath'
meta.setDynamicSourceFileNameField("filename"); // indexOfValue -> -1, throws
// after
meta.setDynamicSourceFileNameField("filepath"); // matches actual stream field
Defensive patterns

Strategy: validation

Validate before calling

// Verify the field exists in the incoming row layout before running
RowMetaInterface prev = transMeta.getPrevStepFields(stepMeta);
String srcField = meta.getDynamicSourceFileNameField();
if (prev != null && srcField != null && prev.indexOfValue(srcField) < 0) {
  throw new IllegalArgumentException("Field '" + srcField + "' not present in input stream");
}

Try / catch

try { trans.execute(null); } catch (KettleException e) { if (e.getMessage().contains("CouldnotFindField")) { log.error("Input stream lacks the configured filename field", e); } throw e; }

Prevention

When it happens

Trigger: First row arrives and indexOfValue(meta.getDynamicSourceFileNameField()) < 0: the upstream step doesn't produce the configured field, the field was renamed, or case/spelling differs.

Common situations: Upstream Select Values/renamed field; transformation changed upstream after configuring this step; running a transformation where the source field is computed conditionally and absent.

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/156fc60a582fa9eb. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/processfiles/ProcessFiles.java:80

    }
    if ( first ) {
      first = false;
      // Check is source filename field is provided
      if ( Utils.isEmpty( meta.getDynamicSourceFileNameField() ) ) {
        throw new KettleException( BaseMessages.getString( PKG, "ProcessFiles.Error.SourceFilenameFieldMissing" ) );
      }
      // Check is target filename field is provided
      if ( meta.getOperationType() != ProcessFilesMeta.OPERATION_TYPE_DELETE
        && Utils.isEmpty( meta.getDynamicTargetFileNameField() ) ) {
        throw new KettleException( BaseMessages.getString( PKG, "ProcessFiles.Error.TargetFilenameFieldMissing" ) );
      }

      // cache the position of the source filename field
      if ( data.indexOfSourceFilename < 0 ) {
        data.indexOfSourceFilename = getInputRowMeta().indexOfValue( meta.getDynamicSourceFileNameField() );
        if ( data.indexOfSourceFilename < 0 ) {
          // The field is unreachable !
          throw new KettleException( BaseMessages.getString( PKG, "ProcessFiles.Exception.CouldnotFindField", meta
            .getDynamicSourceFileNameField() ) );
        }
      }
      // cache the position of the source filename field
      if ( meta.getOperationType() != ProcessFilesMeta.OPERATION_TYPE_DELETE && data.indexOfTargetFilename < 0 ) {
        data.indexOfTargetFilename = getInputRowMeta().indexOfValue( meta.getDynamicTargetFileNameField() );
        if ( data.indexOfTargetFilename < 0 ) {
          // The field is unreachable !
          throw new KettleException( BaseMessages.getString( PKG, "ProcessFiles.Exception.CouldnotFindField", meta
            .getDynamicTargetFileNameField() ) );
        }
      }

      if ( meta.simulate ) {
        if ( log.isBasic() ) {
          logBasic( BaseMessages.getString( PKG, "ProcessFiles.Log.SimulationModeON" ) );
        }
      }

View on GitHub (pinned to f3058517a1)