pentaho/pentaho-kettle · error · KettleException

ChangeFileEncoding.Exception.CouldnotFindField

ChangeFileEncoding.Exception.CouldnotFindField

Error message

ChangeFileEncoding.Exception.CouldnotFindField

What it means

The step resolves the source filename field by name via data.inputRowMeta.indexOfValue(meta.getDynamicFilenameField()). When the configured field does not exist in the incoming row stream (index < 0), it throws this localized KettleException naming the missing field.

Solutions

  1. Check the incoming row layout (e.g. with 'Fields' preview or 'Get fields' in the dialog) and select the correct field name.
  2. Add/repair an upstream step (e.g. Get File Names, Modified Java Script Value) that produces the filename field.
  3. Correct typos/case in the configured field name.
  4. Verify the input hop comes from the intended step.

Example fix

// before
meta.setDynamicFilenameField("file_nm "); // typo + trailing space
// after
meta.setDynamicFilenameField("file_name"); // exact field in stream
Defensive patterns

Strategy: validation

Validate before calling

int idx = inputRowMeta.indexOfValue(meta.getDynamicFilenameField());
if (idx < 0) {
  throw new IllegalArgumentException("Field not found in input stream: " + meta.getDynamicFilenameField());
}

Try / catch

try {
  // execute transformation
} catch (KettleException e) {
  if (e.getMessage().contains("CouldnotFindField")) {
    // fix field name/upstream step
  } else { throw e; }
}

Prevention

When it happens

Trigger: processRow on each first row after configuration checks pass: indexOfValue returns -1 because no value in the input RowMeta matches the 'Filename fieldname' string.

Common situations: Upstream step renamed or removed the field; the field is produced downstream instead of upstream; case mismatch or trailing spaces in the configured field name; the wrong input hop is wired.

Related errors


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

Appendix: source

Thrown at plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java:91

      // Check is source filename field is provided
      if ( Utils.isEmpty( meta.getDynamicFilenameField() ) ) {
        logError( BaseMessages.getString( PKG, "ChangeFileEncoding.Error.FilenameFieldMissing" ) );
        throw new KettleException( BaseMessages.getString( PKG, "ChangeFileEncoding.Error.FilenameFieldMissing" ) );
      }

      // Check is target filename field is provided
      if ( Utils.isEmpty( meta.getTargetFilenameField() ) ) {
        throw new KettleException(
            BaseMessages.getString( PKG, "ChangeFileEncoding.Error.TargetFilenameFieldMissing" ) );
      }

      // cache the position of the field
      data.indexOfFileename = data.inputRowMeta.indexOfValue( meta.getDynamicFilenameField() );
      if ( data.indexOfFileename < 0 ) {
        // The field is unreachable !
        logError( BaseMessages.getString( PKG, "ChangeFileEncoding.Exception.CouldnotFindField" ) + "["
            + meta.getDynamicFilenameField() + "]" );
        throw new KettleException( BaseMessages.getString( PKG, "ChangeFileEncoding.Exception.CouldnotFindField",
          meta.getDynamicFilenameField() ) );
      }
      // cache the position of the field
      data.indexOfTargetFileename = data.inputRowMeta.indexOfValue( meta.getTargetFilenameField() );
      if ( data.indexOfTargetFileename < 0 ) {
        // The field is unreachable !
        logError( BaseMessages.getString( PKG, "ChangeFileEncoding.Exception.CouldnotFindField" ) + "["
            + meta.getTargetFilenameField() + "]" );
        throw new KettleException( BaseMessages.getString( PKG, "ChangeFileEncoding.Exception.CouldnotFindField",
          meta.getTargetFilenameField() ) );
      }

      // Check source encoding
      data.sourceEncoding = environmentSubstitute( meta.getSourceEncoding() );

      // if(Utils.isEmpty(data.sourceEncoding)) {
      // throw new KettleException(BaseMessages.getString(PKG, "ChangeFileEncoding.Exception.SourceEncodingEmpty"));
      // }

View on GitHub (pinned to f3058517a1)