{"record":{"id":"b5670a24f187e24b","repo":"pentaho/pentaho-kettle","slug":"selected-field-fieldname-couldn-t-be-found-in-file-filename","errorCode":null,"errorMessage":"Selected field '{fieldName}' couldn't be found in file '{filename}'","messagePattern":"Selected field '(.+?)' couldn't be found in file '(.+?)'","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/sasinput/SasInput.java","lineNumber":139,"sourceCode":"        }\n        if ( first.getType() != second.getType() ) {\n          throw new KettleException( \"Field nr \"\n            + i + \" in file '\" + filename + \"' is of data type '\" + second.getTypeDesc() + \"' while it was '\"\n            + first.getTypeDesc() + \"' in the first file\" );\n        }\n      }\n    }\n\n    // Also make sure that we only read the specified fields, not any other...\n    //\n    if ( first ) {\n      first = false;\n\n      data.fieldIndexes = new ArrayList<Integer>();\n      for ( SasInputField field : meta.getOutputFields() ) {\n        int fieldIndex = data.fileLayout.indexOfValue( field.getName() );\n        if ( fieldIndex < 0 ) {\n          throw new KettleException( \"Selected field '\"\n            + field.getName() + \"' couldn't be found in file '\" + filename + \"'\" );\n        }\n        data.fieldIndexes.add( fieldIndex );\n      }\n    }\n\n    // Add this to the result file names...\n    //\n    ResultFile resultFile =\n      new ResultFile( ResultFile.FILE_TYPE_GENERAL, KettleVFS.getInstance( getTransMeta().getBowl() )\n                      .getFileObject( filename ), getTransMeta()\n        .getName(), getStepname() );\n    resultFile.setComment( BaseMessages.getString( PKG, \"SASInput.ResultFile.Comment\" ) );\n    addResultFile( resultFile );\n\n    SasReader sasReader = new SasReader( new File( filename ) );\n    sasReader.read( new SasReaderCallback() {\n      private boolean firstRead = true;","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/sasinput/SasInput.java#L121-L157","documentation":"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.","triggerScenarios":"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.","commonSituations":"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').","solutions":["Open the step dialog, run 'Get fields', and reselect the correct field names from the actual file layout.","Fix the typo/case in the configured field name so it exactly matches a column in the SAS file.","Remove the stale output field entry if the column was intentionally dropped from the file."],"exampleFix":"// before (step metadata XML): <field_name>amont</field_name>\n// after: <field_name>amount</field_name>","handlingStrategy":"validation","validationCode":"// Validate configured output fields exist in the file before running\nSet<String> available = layoutFieldNames(file); // from the SAS file layout\nfor (String name : configuredOutputFieldNames) {\n  if (!available.contains(name))\n    throw new IllegalArgumentException(\"Field '\" + name + \"' not present in \" + file);\n}","typeGuard":null,"tryCatchPattern":"try {\n  // run transformation / step init\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"couldn't be found in file\")) {\n    // fix step metadata: reselect fields via 'Get fields'\n  }\n  throw e;\n}","preventionTips":["Always use the step's 'Get fields' button instead of typing field names manually.","Re-validate field selections after any upstream schema change.","Keep transformations and their source files versioned together."],"tags":["sas","field-not-found","configuration","etl"],"backgroundTag":"resource-not-found","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}