{"record":{"id":"71ac54b3476bc5b0","repo":"pentaho/pentaho-kettle","slug":"changefileencoding-exception-couldnotfindfield","errorCode":"ChangeFileEncoding.Exception.CouldnotFindField","errorMessage":"ChangeFileEncoding.Exception.CouldnotFindField","messagePattern":"ChangeFileEncoding\\.Exception\\.CouldnotFindField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java","lineNumber":91,"sourceCode":"      // Check is source filename field is provided\n      if ( Utils.isEmpty( meta.getDynamicFilenameField() ) ) {\n        logError( BaseMessages.getString( PKG, \"ChangeFileEncoding.Error.FilenameFieldMissing\" ) );\n        throw new KettleException( BaseMessages.getString( PKG, \"ChangeFileEncoding.Error.FilenameFieldMissing\" ) );\n      }\n\n      // Check is target filename field is provided\n      if ( Utils.isEmpty( meta.getTargetFilenameField() ) ) {\n        throw new KettleException(\n            BaseMessages.getString( PKG, \"ChangeFileEncoding.Error.TargetFilenameFieldMissing\" ) );\n      }\n\n      // cache the position of the field\n      data.indexOfFileename = data.inputRowMeta.indexOfValue( meta.getDynamicFilenameField() );\n      if ( data.indexOfFileename < 0 ) {\n        // The field is unreachable !\n        logError( BaseMessages.getString( PKG, \"ChangeFileEncoding.Exception.CouldnotFindField\" ) + \"[\"\n            + meta.getDynamicFilenameField() + \"]\" );\n        throw new KettleException( BaseMessages.getString( PKG, \"ChangeFileEncoding.Exception.CouldnotFindField\",\n          meta.getDynamicFilenameField() ) );\n      }\n      // cache the position of the field\n      data.indexOfTargetFileename = data.inputRowMeta.indexOfValue( meta.getTargetFilenameField() );\n      if ( data.indexOfTargetFileename < 0 ) {\n        // The field is unreachable !\n        logError( BaseMessages.getString( PKG, \"ChangeFileEncoding.Exception.CouldnotFindField\" ) + \"[\"\n            + meta.getTargetFilenameField() + \"]\" );\n        throw new KettleException( BaseMessages.getString( PKG, \"ChangeFileEncoding.Exception.CouldnotFindField\",\n          meta.getTargetFilenameField() ) );\n      }\n\n      // Check source encoding\n      data.sourceEncoding = environmentSubstitute( meta.getSourceEncoding() );\n\n      // if(Utils.isEmpty(data.sourceEncoding)) {\n      // throw new KettleException(BaseMessages.getString(PKG, \"ChangeFileEncoding.Exception.SourceEncodingEmpty\"));\n      // }","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java#L73-L109","documentation":"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.","triggerScenarios":"processRow on each first row after configuration checks pass: indexOfValue returns -1 because no value in the input RowMeta matches the 'Filename fieldname' string.","commonSituations":"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.","solutions":["Check the incoming row layout (e.g. with 'Fields' preview or 'Get fields' in the dialog) and select the correct field name.","Add/repair an upstream step (e.g. Get File Names, Modified Java Script Value) that produces the filename field.","Correct typos/case in the configured field name.","Verify the input hop comes from the intended step."],"exampleFix":"// before\nmeta.setDynamicFilenameField(\"file_nm \"); // typo + trailing space\n// after\nmeta.setDynamicFilenameField(\"file_name\"); // exact field in stream","handlingStrategy":"validation","validationCode":"int idx = inputRowMeta.indexOfValue(meta.getDynamicFilenameField());\nif (idx < 0) {\n  throw new IllegalArgumentException(\"Field not found in input stream: \" + meta.getDynamicFilenameField());\n}","typeGuard":null,"tryCatchPattern":"try {\n  // execute transformation\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"CouldnotFindField\")) {\n    // fix field name/upstream step\n  } else { throw e; }\n}","preventionTips":["Re-select fields with 'Get fields' after changing upstream steps","Avoid renaming/removing fields feeding this step","Preview the input hop to verify field names"],"tags":["kettle","row-stream","missing-field"],"backgroundTag":"field-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"}