pentaho/pentaho-kettle · error · KettleException

Selected field ' ' couldn't be found in file

Error message

Selected field '{fieldName}' couldn't be found in file '{filename}'

What it means

After loading the SAS file layout, the step resolves each configured output field against data.fileLayout. If indexOfValue returns < 0, the configured field name does not exist in the SAS file, and processRow throws this KettleException.

Solutions

  1. Open the step dialog, run 'Get fields', and reselect the correct field names from the actual file layout.
  2. Fix the typo/case in the configured field name so it exactly matches a column in the SAS file.
  3. Remove the stale output field entry if the column was intentionally dropped from the file.

Example fix

// before (step metadata XML): <field_name>amont</field_name>
// after: <field_name>amount</field_name>
Defensive patterns

Strategy: validation

Validate before calling

// Validate configured output fields exist in the file before running
Set<String> available = layoutFieldNames(file); // from the SAS file layout
for (String name : configuredOutputFieldNames) {
  if (!available.contains(name))
    throw new IllegalArgumentException("Field '" + name + "' not present in " + file);
}

Try / catch

try {
  // run transformation / step init
} catch (KettleException e) {
  if (e.getMessage().contains("couldn't be found in file")) {
    // fix step metadata: reselect fields via 'Get fields'
  }
  throw e;
}

Prevention

When it happens

Trigger: The step's Output Fields list contains a field name that is not a column in the specified SAS7BAT file (indexOfValue fails). Field names are case-sensitive here since indexOfValue is used.

Common situations: Typo in the configured output field name; field renamed in the SAS file after the step was configured; copying a transformation between environments with different file schemas; case-sensitivity differences ('Amount' vs 'amount').

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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/sasinput/SasInput.java:139

        }
        if ( first.getType() != second.getType() ) {
          throw new KettleException( "Field nr "
            + i + " in file '" + filename + "' is of data type '" + second.getTypeDesc() + "' while it was '"
            + first.getTypeDesc() + "' in the first file" );
        }
      }
    }

    // Also make sure that we only read the specified fields, not any other...
    //
    if ( first ) {
      first = false;

      data.fieldIndexes = new ArrayList<Integer>();
      for ( SasInputField field : meta.getOutputFields() ) {
        int fieldIndex = data.fileLayout.indexOfValue( field.getName() );
        if ( fieldIndex < 0 ) {
          throw new KettleException( "Selected field '"
            + field.getName() + "' couldn't be found in file '" + filename + "'" );
        }
        data.fieldIndexes.add( fieldIndex );
      }
    }

    // Add this to the result file names...
    //
    ResultFile resultFile =
      new ResultFile( ResultFile.FILE_TYPE_GENERAL, KettleVFS.getInstance( getTransMeta().getBowl() )
                      .getFileObject( filename ), getTransMeta()
        .getName(), getStepname() );
    resultFile.setComment( BaseMessages.getString( PKG, "SASInput.ResultFile.Comment" ) );
    addResultFile( resultFile );

    SasReader sasReader = new SasReader( new File( filename ) );
    sasReader.read( new SasReaderCallback() {
      private boolean firstRead = true;

View on GitHub (pinned to f3058517a1)