{"record":{"id":"3f58f39fa7efae1c","repo":"pentaho/pentaho-kettle","slug":"error-finding-id-for-directory-repositorydirectory-and-name","errorCode":null,"errorMessage":"Error finding ID for directory [ + repositoryDirectory + ] and name [ + name + ]","messagePattern":"Error finding ID for directory \\[ \\+ repositoryDirectory \\+ \\] and name \\[ \\+ name \\+ \\]","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/filerep/KettleFileRepository.java","lineNumber":512,"sourceCode":"    return new ObjectId[] {};\n  }\n\n  public ObjectId[] getDatabaseAttributeIDs( ObjectId id_database ) throws KettleException {\n    return new ObjectId[] {};\n  }\n\n  private ObjectId getObjectId( RepositoryDirectoryInterface repositoryDirectory, String name, String extension ) throws KettleException {\n    try {\n      String filename = calcFilename( repositoryDirectory, name, extension );\n      if ( !KettleVFS.getInstance( DefaultBowl.getInstance() ).getFileObject( filename ).exists() ) {\n        return null;\n      }\n\n      // The ID is the filename relative to the base directory, including the file extension\n      //\n      return new StringObjectId( calcObjectId( repositoryDirectory, name, extension ) );\n    } catch ( Exception e ) {\n      throw new KettleException( \"Error finding ID for directory [\"\n        + repositoryDirectory + \"] and name [\" + name + \"]\", e );\n    }\n  }\n\n  @Override\n  public ObjectId getDatabaseID( String name ) throws KettleException {\n    ObjectId match = getObjectId( null, name, EXT_DATABASE );\n    if ( match == null ) {\n      // exact match failed, trying to find the DB case-insensitively\n      ObjectId[] existingIds = getDatabaseIDs( false );\n      String[] existingNames = getDatabaseNames( existingIds );\n      int index = DatabaseMeta.indexOfName( existingNames, name );\n      if ( index != -1 ) {\n        return getObjectId( null, existingNames[ index ], EXT_DATABASE );\n      }\n    }\n\n    return match;","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/filerep/KettleFileRepository.java#L494-L530","documentation":"In KettleFileRepository, object IDs are filenames relative to the base directory. getObjectId() resolves the ID for a named object in a directory by computing that filename; any exception during resolution (bad directory, invalid name, extension problems) is wrapped in this KettleException. Callers include match(), getDatabaseID(), getJobId(), and getTransformationID().","triggerScenarios":"Calling getDatabaseID/getJobId/getTransformationID (or delObject/match paths) with a name that cannot be mapped to a file, or a repository directory whose path cannot be computed — e.g. directory with null/unset path, or name containing illegal filename characters.","commonSituations":"Looking up an object in a directory object that was never loaded/refreshed from the file repository; object names containing characters invalid in filenames (slash, colon); stale directory references after the underlying folder tree was moved.","solutions":["Check the chained cause for the underlying resolution failure.","Refresh/reload the RepositoryDirectory tree from the repository before lookups.","Sanitize object names — remove filesystem-illegal characters before calling.","Confirm the object's extension/type is supported by the file repository mapping."],"exampleFix":"// before: stale directory handle\nObjectId id = repo.getTransformationID(name, staleDir);\n\n// after: re-resolve the directory tree first\nRepositoryDirectoryInterface dir = repo.loadRepositoryDirectoryTree()\n    .findDirectory(dirPath);\nObjectId id = repo.getTransformationID(sanitize(name), dir);","handlingStrategy":"validation","validationCode":"// reload the directory tree and sanitize names before lookups\nRepositoryDirectoryInterface dir = repo.loadRepositoryDirectoryTree().findDirectory(dirPath);\nString safeName = name.replaceAll(\"[\\\\/:*?\\\"<>|]\", \"_\");","typeGuard":"boolean directoryUsable(RepositoryDirectoryInterface d) {\n  return d != null && d.getPath() != null;\n}","tryCatchPattern":"try {\n  ObjectId id = repo.getTransformationID(name, dir);\n} catch (KettleException e) {\n  if (e.getMessage().startsWith(\"Error finding ID for directory\")) {\n    log.error(\"Lookup failed for [\" + name + \"] in [\" + dir + \"]: \" + e.getCause());\n  } else { throw e; }\n}","preventionTips":["Reload loadRepositoryDirectoryTree() before resolving IDs in a changed repo","Sanitize object names of filesystem-illegal characters","Confirm the directory handle comes from the current repository tree, not a stale one","Check the chained cause to see whether the name or the directory path failed"],"tags":["kettle","file-repository","object-id","lookup"],"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"}