{"record":{"id":"b676bdc9c5014f00","repo":"pentaho/pentaho-kettle","slug":"could-not-find-folder-id","errorCode":null,"errorMessage":"Could not find folder [ + id + ]","messagePattern":"Could not find folder \\[ \\+ id \\+ \\]","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/filerep/KettleFileRepository.java","lineNumber":1212,"sourceCode":"  public ObjectId renameJob( ObjectId id_job, String versionComment, RepositoryDirectoryInterface newDir,\n    String newName ) throws KettleException {\n    ObjectId objectId = renameObject( id_job, newDir, newName, EXT_JOB );\n    if ( !Utils.isEmpty( versionComment ) ) {\n      insertLogEntry( \"Rename job : \" + versionComment );\n    }\n    return objectId;\n  }\n\n  @Override\n  public ObjectId renameRepositoryDirectory( ObjectId id, RepositoryDirectoryInterface newParentDir, String newName ) throws KettleException {\n    if ( newParentDir != null || newName != null ) {\n      try {\n        // In case of a root object, the ID is the same as the relative filename...\n        RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree();\n        RepositoryDirectoryInterface dir = tree.findDirectory( id );\n\n        if ( dir == null ) {\n          throw new KettleException( \"Could not find folder [\" + id + \"]\" );\n        }\n\n        // If newName is null, keep the current name\n        newName = ( newName != null ) ? newName : dir.getName();\n\n        FileObject folder = KettleVFS.getInstance( DefaultBowl.getInstance() ).getFileObject( dir.getPath() );\n\n        String newFolderName = null;\n\n        if ( newParentDir != null ) {\n          FileObject newParentFolder = KettleVFS.getInstance( DefaultBowl.getInstance() )\n            .getFileObject( newParentDir.getPath() );\n\n          newFolderName = newParentFolder.toString() + \"/\" + newName;\n        } else {\n          newFolderName = folder.getParent().toString() + \"/\" + newName;\n        }\n","sourceCodeStart":1194,"sourceCodeEnd":1230,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/filerep/KettleFileRepository.java#L1194-L1230","documentation":"KettleFileRepository.renameRepositoryObject() (directory branch) throws this KettleException when loadRepositoryDirectoryTree().findDirectory(id) returns null, i.e. the given ObjectId does not correspond to any folder in the repository directory tree.","triggerScenarios":"Renaming a directory using an ObjectId that is not present in the freshly loaded directory tree - typically a stale/deleted directory id or a malformed path string used as the id.","commonSituations":"Directory was deleted or moved by another client before the rename; caller passed a raw filename instead of a valid directory ObjectId; cached directory ids used after the repository tree changed.","solutions":["Reload the repository directory tree and verify the directory exists before renaming","Check that the id passed is a valid directory ObjectId (root-relative path) rather than an object id","Refresh/reopen the repository to discard stale cached ids","Handle the KettleException and surface 'folder not found' to the user instead of retrying"],"exampleFix":"// before\nrepo.renameRepositoryObject(oldDirId, null, \"new-name\"); // oldDirId may be stale\n// after\nRepositoryDirectoryInterface dir = repo.loadRepositoryDirectoryTree().findDirectory(\"/old\");\nif (dir != null) {\n  repo.renameRepositoryObject(dir.getObjectId(), null, \"new-name\");\n}","handlingStrategy":"validation","validationCode":"RepositoryDirectoryInterface dir = repo.loadRepositoryDirectoryTree().findDirectory(idPath);\nif (dir == null) {\n  throw new IllegalArgumentException(\"Folder not found: \" + idPath);\n}","typeGuard":null,"tryCatchPattern":"try {\n  repo.renameRepositoryObject(dirId, null, newName);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"Could not find folder\")) {\n    log.warn(\"Directory vanished; refreshing tree\");\n  }\n}","preventionTips":["Re-resolve directory ids from loadRepositoryDirectoryTree() immediately before use","Do not reuse ids after repository modifications","Confirm callers pass directory ObjectIds, not object filenames"],"tags":["repository","directory","rename","not-found"],"backgroundTag":"directory-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"}