{"record":{"id":"5b2968bb0417df69","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-id-for-type-name","errorCode":null,"errorMessage":"Unable to get ID for [type] [name]","messagePattern":"Unable to get ID for \\[type\\] \\[name\\]","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/PurRepository.java","lineNumber":1037,"sourceCode":"\n  private ObjectId getObjectID( String name, RepositoryObjectType type ) throws KettleException {\n    try {\n      ObjectId objectId = getObjectId( name, null, type, false );\n      if ( objectId == null ) {\n        List<RepositoryFile> allFilesOfType = getAllFilesOfType( null, type, false );\n        String[] existingNames = new String[ allFilesOfType.size() ];\n        for ( int i = 0; i < allFilesOfType.size(); i++ ) {\n          RepositoryFile file = allFilesOfType.get( i );\n          existingNames[ i ] = file.getTitle();\n        }\n        int index = DatabaseMeta.indexOfName( existingNames, name );\n        if ( index != -1 ) {\n          return new StringObjectId( allFilesOfType.get( index ).getId().toString() );\n        }\n      }\n      return objectId;\n    } catch ( Exception e ) {\n      throw new KettleException( \"Unable to get ID for \" + type + \" [\" + name + \"]\", e );\n    }\n  }\n\n  /**\n   * Copying the behavior of the original JCRRepository, this implementation returns IDs of deleted objects too.\n   */\n  private ObjectId getObjectId( final String name, final RepositoryDirectoryInterface dir,\n                                final RepositoryObjectType objectType, boolean includedDeleteFiles ) {\n    final String absPath = getPath( name, dir, objectType );\n\n    readWriteLock.readLock().lock();\n    try {\n      RepositoryFile file;\n      file = pur.getFile( absPath );\n\n      if ( file != null ) {\n        // file exists\n        return new StringObjectId( file.getId().toString() );","sourceCodeStart":1019,"sourceCodeEnd":1055,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/PurRepository.java#L1019-L1055","documentation":"getObjectID(name, type) failed: it resolves an object name of a given RepositoryObjectType to its ObjectId by listing all files of that type and matching the title; any exception is wrapped as 'Unable to get ID for [type] [name]'. Returns null-ish objectId when not found; throws only when the lookup itself fails.","triggerScenarios":"Calling getDatabaseID/getClusterID/etc. (all delegating to getObjectID) when the listing of all files of the type throws, or when matching logic fails unexpectedly — bad type, service error, unreadable folder.","commonSituations":"Looking up a transformation/job/database by name against a folder the user cannot read; passing a name that never existed (not an exception here, returns null); server connectivity loss.","solutions":["Check the wrapped cause first: distinguish lookup failure (throw) from not-found (returns null).","Verify the object exists via the repository browser UI before resolving its ID by name.","Ensure the user has read access to the folder containing that object type.","Handle the null return for missing names instead of relying on exceptions."],"exampleFix":"// before\nObjectId id = repo.getDatabaseID(\"MySQL DW\");\n// after\nObjectId id = repo.getDatabaseID(\"MySQL DW\");\nif (id == null) {\n  throw new KettleException(\"Database 'MySQL DW' not found\");\n}","handlingStrategy":"validation","validationCode":"if (name == null || name.isBlank()) throw new IllegalArgumentException(\"Name required for ID lookup\");","typeGuard":"null","tryCatchPattern":"try {\n  id = repo.getDatabaseID(name);\n} catch (KettleException e) {\n  log.error(\"ID lookup for {} failed: {}\", name, e.getCause());\n  throw e;\n}\nif (id == null) throw new KettleException(name + \" not found\");","preventionTips":["Distinguish null (not found) from thrown exceptions (lookup failure).","Confirm read access to the type's folder before name lookups.","Cache resolved IDs only for the current session."],"tags":["repository","object-lookup","pentaho","id-resolution"],"backgroundTag":"record-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"}