{"record":{"id":"b3c90c6db3107ee7","repo":"pentaho/pentaho-kettle","slug":"filelocked-exception-couldnotfindfield","errorCode":"FileLocked.Exception.CouldnotFindField","errorMessage":"FileLocked.Exception.CouldnotFindField","messagePattern":"FileLocked\\.Exception\\.CouldnotFindField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/filelocked/FileLocked.java","lineNumber":86,"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 filename field is provided\n      if ( Utils.isEmpty( meta.getDynamicFilenameField() ) ) {\n        logError( BaseMessages.getString( PKG, \"FileLocked.Error.FilenameFieldMissing\" ) );\n        throw new KettleException( BaseMessages.getString( PKG, \"FileLocked.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, \"FileLocked.Exception.CouldnotFindField\" )\n            + \"[\" + meta.getDynamicFilenameField() + \"]\" );\n          throw new KettleException( BaseMessages.getString( PKG, \"FileLocked.Exception.CouldnotFindField\", meta\n            .getDynamicFilenameField() ) );\n        }\n      }\n    } // End If first\n\n    try {\n      // get filename\n      String filename = data.previousRowMeta.getString( r, data.indexOfFileename );\n      if ( !Utils.isEmpty( filename ) ) {\n        // Check if file\n        LockFile locked = new LockFile( getTransMeta().getBowl(), filename );\n        FileLocked = locked.isLocked();\n\n        // add filename to result filenames?\n        if ( meta.addResultFilenames() ) {\n          // Add this to the result file names...\n          ResultFile resultFile =\n            new ResultFile( ResultFile.FILE_TYPE_GENERAL, KettleVFS.getInstance( getTransMeta().getBowl() )","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/filelocked/FileLocked.java#L68-L104","documentation":"After locating the configured dynamic filename field, FileLocked caches its index in the previous row's metadata. If indexOfValue() returns -1 the configured field does not exist in the incoming row stream, so the step cannot determine which file to check and throws this KettleException.","triggerScenarios":"processRow() on the first row: meta.getDynamicFilenameField() is non-empty but data.previousRowMeta.indexOfValue(...) returns -1 because the upstream step does not emit a field with that exact name.","commonSituations":"Typo or case mismatch between the configured field name and the actual output field; an upstream step was renamed or removed; field is only produced conditionally; connecting the step to the wrong hop.","solutions":["Verify the field name configured in the step matches exactly (case-sensitive) a field in the incoming stream - use 'Get fields' in the dialog.","Add or fix the upstream step so it outputs the filename field (e.g. Text File Input, Get File Names, JavaScript).","Preview the previous step to confirm the actual output field names, then re-select the field in the FileLocked dialog."],"exampleFix":"// before\nmeta.setDynamicFilenameField(\"filenames\"); // upstream field is actually 'filename'\n// after\nmeta.setDynamicFilenameField(\"filename\");","handlingStrategy":"validation","validationCode":"// Confirm the field exists in the incoming stream before execution:\nString field = meta.getDynamicFilenameField();\nif (prevRowMeta.indexOfValue(field) < 0) {\n  throw new IllegalStateException(\"Field '\" + field + \"' not present in previous step output\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  trans.execute(null);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"CouldnotFindField\")) {\n    log.error(\"Check FileLocked step field name against upstream output\", e);\n  }\n  throw e;\n}","preventionTips":["Use the dialog's field picker instead of typing field names.","Preview the previous step to confirm actual field names before wiring the step.","Avoid renaming upstream fields without re-checking downstream steps."],"tags":["kettle","field-lookup","row-metadata"],"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"}