{"record":{"id":"156fc60a582fa9eb","repo":"pentaho/pentaho-kettle","slug":"processfiles-exception-couldnotfindfield","errorCode":null,"errorMessage":"ProcessFiles.Exception.CouldnotFindField","messagePattern":"ProcessFiles\\.Exception\\.CouldnotFindField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/processfiles/ProcessFiles.java","lineNumber":80,"sourceCode":"    }\n    if ( first ) {\n      first = false;\n      // Check is source filename field is provided\n      if ( Utils.isEmpty( meta.getDynamicSourceFileNameField() ) ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"ProcessFiles.Error.SourceFilenameFieldMissing\" ) );\n      }\n      // Check is target filename field is provided\n      if ( meta.getOperationType() != ProcessFilesMeta.OPERATION_TYPE_DELETE\n        && Utils.isEmpty( meta.getDynamicTargetFileNameField() ) ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"ProcessFiles.Error.TargetFilenameFieldMissing\" ) );\n      }\n\n      // cache the position of the source filename field\n      if ( data.indexOfSourceFilename < 0 ) {\n        data.indexOfSourceFilename = getInputRowMeta().indexOfValue( meta.getDynamicSourceFileNameField() );\n        if ( data.indexOfSourceFilename < 0 ) {\n          // The field is unreachable !\n          throw new KettleException( BaseMessages.getString( PKG, \"ProcessFiles.Exception.CouldnotFindField\", meta\n            .getDynamicSourceFileNameField() ) );\n        }\n      }\n      // cache the position of the source filename field\n      if ( meta.getOperationType() != ProcessFilesMeta.OPERATION_TYPE_DELETE && data.indexOfTargetFilename < 0 ) {\n        data.indexOfTargetFilename = getInputRowMeta().indexOfValue( meta.getDynamicTargetFileNameField() );\n        if ( data.indexOfTargetFilename < 0 ) {\n          // The field is unreachable !\n          throw new KettleException( BaseMessages.getString( PKG, \"ProcessFiles.Exception.CouldnotFindField\", meta\n            .getDynamicTargetFileNameField() ) );\n        }\n      }\n\n      if ( meta.simulate ) {\n        if ( log.isBasic() ) {\n          logBasic( BaseMessages.getString( PKG, \"ProcessFiles.Log.SimulationModeON\" ) );\n        }\n      }","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/processfiles/ProcessFiles.java#L62-L98","documentation":"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.","triggerScenarios":"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.","commonSituations":"Upstream Select Values/renamed field; transformation changed upstream after configuring this step; running a transformation where the source field is computed conditionally and absent.","solutions":["Ensure the upstream step actually emits the configured field name (check with 'Preview' or a 'Field existence' check).","Correct the 'Source filename fieldname' setting to match the exact field name in the stream.","Add/repair the upstream step (e.g., Text File Input, Select Values) that produces the filename field."],"exampleFix":"// before: settings say 'filename' but stream has 'filepath'\nmeta.setDynamicSourceFileNameField(\"filename\"); // indexOfValue -> -1, throws\n// after\nmeta.setDynamicSourceFileNameField(\"filepath\"); // matches actual stream field","handlingStrategy":"validation","validationCode":"// Verify the field exists in the incoming row layout before running\nRowMetaInterface prev = transMeta.getPrevStepFields(stepMeta);\nString srcField = meta.getDynamicSourceFileNameField();\nif (prev != null && srcField != null && prev.indexOfValue(srcField) < 0) {\n  throw new IllegalArgumentException(\"Field '\" + srcField + \"' not present in input stream\");\n}","typeGuard":null,"tryCatchPattern":"try { trans.execute(null); } catch (KettleException e) { if (e.getMessage().contains(\"CouldnotFindField\")) { log.error(\"Input stream lacks the configured filename field\", e); } throw e; }","preventionTips":["Preview upstream rows to confirm field names before wiring","Avoid renaming upstream fields without updating downstream steps","Run Spoon's 'Verify transformation' check before production runs"],"tags":["kettle","row-fields","configuration"],"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"}