{"record":{"id":"017d19b67a07b71d","repo":"pentaho/pentaho-kettle","slug":"an-error-occured-loading-the-directory-tree-from-the","errorCode":null,"errorMessage":"An error occured loading the directory tree from the repository","messagePattern":"An error occured loading the directory tree from the repository","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryDirectoryDelegate.java","lineNumber":100,"sourceCode":"    return repositoryDirectory;\n  }\n\n  public RepositoryDirectoryInterface loadRepositoryDirectoryTree( RepositoryDirectoryInterface root ) throws KettleException {\n    try {\n      synchronized ( repository ) {\n\n        root.clear();\n        ObjectId[] subids = repository.getSubDirectoryIDs( root.getObjectId() );\n        for ( int i = 0; i < subids.length; i++ ) {\n          RepositoryDirectory subdir = new RepositoryDirectory();\n          loadRepositoryDirectory( subdir, subids[i] );\n          root.addSubdirectory( subdir );\n        }\n      }\n\n      return root;\n    } catch ( Exception e ) {\n      throw new KettleException( \"An error occured loading the directory tree from the repository\", e );\n    }\n  }\n\n  public void loadRepositoryDirectory( RepositoryDirectory repositoryDirectory, ObjectId id_directory ) throws KettleException {\n    if ( id_directory == null ) {\n      // This is the root directory, id = OL\n      id_directory = new LongObjectId( 0L );\n    }\n\n    try {\n      RowMetaAndData row = getDirectory( id_directory );\n      if ( row != null ) {\n        repositoryDirectory.setObjectId( id_directory );\n\n        // Content?\n        //\n        repositoryDirectory.setName( row.getString( \"DIRECTORY_NAME\", null ) );\n","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryDirectoryDelegate.java#L82-L118","documentation":"Wraps any exception raised while recursively loading the repository directory tree (RepositoryDirectory tree) starting at the root. Any failure walking R_REPOSITORY_LOG/directory rows or building subdirectories is wrapped into this KettleException, with the original exception attached as cause.","triggerScenarios":"Calling loadRepositoryDirectoryTree() when reading directory rows from the repository tables throws: SQL error, missing directory table, corrupt parent/child id links, or connection failure.","commonSituations":"Corrupted directory tree after an interrupted delete/move; cyclic or dangling id_directory_parent references from a bad import; repository DB unreachable mid-load; missing privileges on the directory table.","solutions":["Inspect the cause exception for the exact SQL/row failure","Verify directory rows in the repository directory table for dangling or duplicate ids and repair them","Reconnect and retry if the repository connection was dropped","Restore the directory tables from a repository backup if the tree is corrupt"],"exampleFix":"// before\nRepositoryDirectoryInterface tree = repository.loadRepositoryDirectoryTree(); // wraps any failure\n// after: ensure a healthy connection and handle failure gracefully\ntry {\n  RepositoryDirectoryInterface tree = repository.loadRepositoryDirectoryTree();\n} catch (KettleException e) {\n  log.error(\"Directory tree load failed\", e.getCause()); // inspect real cause, repair tables\n}","handlingStrategy":"try-catch","validationCode":"// sanity-check directory table for dangling parent links\nResultSet rs = stmt.executeQuery(\n  \"SELECT COUNT(*) FROM R_REPOSITORY_LOG d WHERE NOT EXISTS (SELECT 1 FROM R_REPOSITORY_LOG p WHERE p.ID_DIRECTORY = d.ID_DIRECTORY_PARENT)\");","typeGuard":null,"tryCatchPattern":"try {\n  RepositoryDirectoryInterface tree = repository.loadRepositoryDirectoryTree();\n} catch (KettleException e) {\n  log.error(\"Directory tree load failed\", e.getCause());\n  // repair directory rows or restore backup, then retry\n}","preventionTips":["Avoid interrupting repository move/delete operations","Back up directory tables before imports and bulk operations","Verify parent/child directory ids after any manual repository surgery"],"tags":["repository","directory-tree","database","load"],"backgroundTag":"database-query-failed","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"}