{"record":{"id":"fd75e9d09b6b20c0","repo":"pentaho/pentaho-kettle","slug":"getsubfolders-exception-couldnotfindfield","errorCode":null,"errorMessage":"GetSubFolders.Exception.CouldnotFindField","messagePattern":"GetSubFolders\\.Exception\\.CouldnotFindField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/getsubfolders/GetSubFolders.java","lineNumber":102,"sourceCode":"\n        // Get total previous fields\n        data.totalpreviousfields = data.inputRowMeta.size();\n\n        // Check is filename field is provided\n        if ( Utils.isEmpty( meta.getDynamicFoldernameField() ) ) {\n          logError( BaseMessages.getString( PKG, \"GetSubFolders.Log.NoField\" ) );\n          throw new KettleException( BaseMessages.getString( PKG, \"GetSubFolders.Log.NoField\" ) );\n        }\n\n        // cache the position of the field\n        if ( data.indexOfFoldernameField < 0 ) {\n          String realDynamicFoldername = environmentSubstitute( meta.getDynamicFoldernameField() );\n          data.indexOfFoldernameField = data.inputRowMeta.indexOfValue( realDynamicFoldername );\n          if ( data.indexOfFoldernameField < 0 ) {\n            // The field is unreachable !\n            logError( BaseMessages.getString( PKG, \"GetSubFolders.Log.ErrorFindingField\" )\n              + \"[\" + realDynamicFoldername + \"]\" );\n            throw new KettleException( BaseMessages.getString(\n              PKG, \"GetSubFolders.Exception.CouldnotFindField\", realDynamicFoldername ) );\n          }\n        }\n      } else {\n        // Create the output row meta-data\n        data.outputRowMeta = new RowMeta();\n        meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,\n          metaStore );\n        // data.nrStepFields= data.outputRowMeta.size();\n\n        data.files = meta.getFolderList( getTransMeta().getBowl(), this );\n        data.filessize = data.files.nrOfFiles();\n        handleMissingFiles();\n\n      }\n      data.nrStepFields = data.outputRowMeta.size();\n\n    } // end if first","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/getsubfolders/GetSubFolders.java#L84-L120","documentation":"GetSubFolders.processRow throws KettleException 'CouldnotFindField' (with the resolved field name) when the configured dynamic folder-name field is not present in the incoming row's RowMeta. The environment-substituted field name is looked up via indexOfValue and returns -1, so the step cannot locate the folder path per row.","triggerScenarios":"indexOfFoldernameField < 0 after indexOfValue(realDynamicFoldername); field name typo, field removed upstream, or variables in the field name resolving to the wrong name.","commonSituations":"Renaming an upstream Select values field without updating this step; using ${VAR} in the field name that doesn't resolve; connecting the step to a different hop than intended.","solutions":["Correct the field name in the step dialog to match the incoming row exactly (case-sensitive).","Check the variable value used in the field name resolves as expected (Ctrl+Shift+K / set variables).","Inspect the upstream row layout (Preview) and reconnect/update the step accordingly.","Re-order steps so the field exists before Get SubFolders runs."],"exampleFix":"// before\nmeta.setDynamicFoldernameField( \"folder_name \" ); // trailing space\n// after\nmeta.setDynamicFoldernameField( \"folder_name\" ); // matches RowMeta","handlingStrategy":"validation","validationCode":"// Verify the field exists in the incoming row before execution\nRowMetaInterface in = transMeta.getPrevStepFields( stepMeta );\nString field = environmentSubstitute( meta.getDynamicFoldernameField() );\nif ( field == null || in.indexOfValue( field ) < 0 )\n  throw new IllegalStateException( \"Field not in stream: \" + field );","typeGuard":null,"tryCatchPattern":"try {\n  trans.execute( null );\n} catch ( KettleException e ) {\n  if ( e.getMessage() != null && e.getMessage().contains( \"CouldnotFindField\" ) ) {\n    // log the offending field name from the message and fix the step/upstream\n  } else throw e;\n}","preventionTips":["Use exact, variable-free field names where possible","Preview data upstream before wiring the step","Search transformations for references when renaming fields","Validate variables used in field names at runtime"],"tags":["kettle","pdi","field","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"}