{"record":{"id":"941bdaf8314d3f71","repo":"pentaho/pentaho-kettle","slug":"fileexists-exception-couldnotfindfield","errorCode":null,"errorMessage":"FileExists.Exception.CouldnotFindField","messagePattern":"FileExists\\.Exception\\.CouldnotFindField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/fileexists/FileExists.java","lineNumber":91,"sourceCode":"        data.NrPrevFields = data.previousRowMeta.size();\n        data.outputRowMeta = data.previousRowMeta;\n        meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,\n          metaStore );\n\n        // Check is tablename field is provided\n        if ( Utils.isEmpty( meta.getDynamicFilenameField() ) ) {\n          logError( BaseMessages.getString( PKG, \"FileExists.Error.FilenameFieldMissing\" ) );\n          throw new KettleException( BaseMessages.getString( PKG, \"FileExists.Error.FilenameFieldMissing\" ) );\n        }\n\n        // cache the position of the field\n        if ( data.indexOfFileename < 0 ) {\n          data.indexOfFileename = data.previousRowMeta.indexOfValue( meta.getDynamicFilenameField() );\n          if ( data.indexOfFileename < 0 ) {\n            // The field is unreachable !\n            logError( BaseMessages.getString( PKG, \"FileExists.Exception.CouldnotFindField\" )\n              + \"[\" + meta.getDynamicFilenameField() + \"]\" );\n            throw new KettleException( BaseMessages.getString( PKG, \"FileExists.Exception.CouldnotFindField\", meta\n              .getDynamicFilenameField() ) );\n          }\n        }\n      } // End If first\n\n      Object[] outputRow = RowDataUtil.allocateRowData( data.outputRowMeta.size() );\n      for ( int i = 0; i < data.NrPrevFields; i++ ) {\n        outputRow[i] = r[i];\n      }\n      // get filename\n      String filename = data.previousRowMeta.getString( r, data.indexOfFileename );\n      if ( !Utils.isEmpty( filename ) ) {\n        data.file = KettleVFS.getInstance( getTransMeta().getBowl() ).getFileObject( filename, getTransMeta() );\n\n        // Check if file\n        fileexists = data.file.exists();\n\n        // include file type?","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/fileexists/FileExists.java#L73-L109","documentation":"After checking the configured filename field name is non-empty, FileExists.processRow() looks it up in the previous step's row metadata with indexOfValue(); if the field is not present in the incoming stream, a KettleException with 'CouldnotFindField' plus the field name is thrown on the first row.","triggerScenarios":"The FileExists step's 'Filename field' names a field that does not exist in the rows arriving from the previous step (typo, renamed upstream field, or wrong hop).","commonSituations":"Upstream step renamed or dropped the field; transformation edited so the hop now comes from a different step; case-sensitive field name mismatch; running after upstream stream changes without re-checking mappings.","solutions":["Make the incoming stream actually contain a field with exactly the configured name (fix the Select Values/upstream step).","Correct the 'Filename field' setting to match an existing incoming field (names are case-sensitive).","Preview the previous step's output to confirm the available field names.","Re-check hop wiring after refactoring the transformation."],"exampleFix":"// before\nmeta.setDynamicFilenameField(\"Filename\"); // stream has 'filename' (lowercase)\n// after\nmeta.setDynamicFilenameField(\"filename\"); // matches incoming field exactly","handlingStrategy":"validation","validationCode":"if (previousRowMeta != null && previousRowMeta.indexOfValue(meta.getDynamicFilenameField()) < 0) {\n  throw new IllegalStateException(\"Incoming stream lacks field: \" + meta.getDynamicFilenameField());\n}","typeGuard":null,"tryCatchPattern":"try {\n  trans.execute(null);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"FileExists.Exception.CouldnotFindField\")) {\n    // align upstream field names with the configured 'Filename field'\n  } else { throw e; }\n}","preventionTips":["Preview the upstream step output and match exact (case-sensitive) field names.","Re-validate mappings after renaming fields upstream.","Use Select Values to add/rename fields explicitly before FileExists.","Check hop wiring after transformation refactors."],"tags":["etl","row-stream","field-lookup"],"backgroundTag":"record-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"}