{"record":{"id":"a145dadc477c3f7c","repo":"pentaho/pentaho-kettle","slug":"csvinput-exception-filenamefieldnotfound-with-filenamefield","errorCode":null,"errorMessage":"CsvInput.Exception.FilenameFieldNotFound (with filenameField)","messagePattern":"CsvInput\\.Exception\\.FilenameFieldNotFound \\(with filenameField\\)","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/csvinput/CsvInput.java","lineNumber":275,"sourceCode":"    }\n  }\n\n  private void getFilenamesFromPreviousSteps() throws KettleException {\n    List<String> filenames = new ArrayList<>();\n    boolean firstRow = true;\n    int index = -1;\n    Object[] row = getRow();\n    while ( row != null ) {\n\n      if ( firstRow ) {\n        firstRow = false;\n\n        // Get the filename field index...\n        //\n        String filenameField = environmentSubstitute( meta.getFilenameField() );\n        index = getInputRowMeta().indexOfValue( filenameField );\n        if ( index < 0 ) {\n          throw new KettleException( BaseMessages.getString(\n            PKG, \"CsvInput.Exception.FilenameFieldNotFound\", filenameField ) );\n        }\n      }\n\n      String filename = getInputRowMeta().getString( row, index );\n      filenames.add( filename ); // add it to the list...\n\n      row = getRow(); // Grab another row...\n    }\n\n    data.filenames = filenames.toArray( new String[ filenames.size() ] );\n\n    logBasic( BaseMessages.getString( PKG, \"CsvInput.Log.ReadingFromNrFiles\", Integer\n      .toString( data.filenames.length ) ) );\n  }\n\n  @Override\n  public void dispose( StepMetaInterface smi, StepDataInterface sdi ) {","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/csvinput/CsvInput.java#L257-L293","documentation":"CsvInput reads a list of filenames from rows arriving on the input stream when 'File passed via field' is enabled. It looks up the configured filename field in the incoming row metadata; if the field does not exist in the input row layout, indexOfValue returns -1 and this KettleException is thrown. It means the step's filenameField setting does not match any column actually produced by the previous step.","triggerScenarios":"'Accept filenames in previous step' is checked and the configured filenameField (after environment substitution) is not present in the incoming row's ValueMeta list, e.g. the field was renamed, removed, or the wrong field name was typed in the step dialog.","commonSituations":"Renaming or deleting the filename column in an upstream step (Text File Input, Get File Names) without updating CsvInput; environment variable substitution producing a different field name; wiring the wrong hop into CsvInput.","solutions":["Open the CsvInput step dialog and set 'The filename field' (FilenameField) to the exact name of the field containing filenames in the incoming rows.","Verify the previous step actually emits that field: preview the previous step and check the field names (case-sensitive).","If the field name contains an environment variable, confirm the variable is set so it resolves to the correct field name."],"exampleFix":"// before (dialog config)\nfilenameField = \"filename\"\n// after (field renamed upstream to filepath)\nfilenameField = \"filepath\"","handlingStrategy":"validation","validationCode":"// before running, verify the incoming row layout contains the field\nString[] fields = transMeta.getPrevStepFields(stepMeta).getFieldNames();\nif (java.util.Arrays.asList(fields).indexOf(envSubstitute(filenameField)) < 0) {\n  throw new IllegalStateException(\"filenameField not in input rows: \" + filenameField);\n}","typeGuard":null,"tryCatchPattern":"try { ... } catch (KettleException e) {\n  logError(\"Filename field '\" + filenameField + \"' missing from input rows\", e);\n  setErrors(1);\n}","preventionTips":["Preview the upstream step and copy the exact field name into FilenameField","Keep field names case-consistent across steps","Re-check step config after renaming any upstream field","Avoid environment variables in field names unless verified at runtime"],"tags":["kettle","pentaho","step-config","field-not-found"],"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"}