{"record":{"id":"ce2f8333adf807a2","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-element","errorCode":null,"errorMessage":"Unable to get element","messagePattern":"Unable to get element","errorType":"exception","errorClass":"MetaStoreException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KettleDatabaseRepositoryMetaStore.java","lineNumber":333,"sourceCode":"  public List<String> getElementIds( String namespace, IMetaStoreElementType elementType ) throws MetaStoreException {\n    List<String> ids = new ArrayList<String>();\n    List<IMetaStoreElement> elements = getElements( namespace, elementType );\n    for ( IMetaStoreElement element : elements ) {\n      ids.add( element.getId() );\n    }\n    return ids;\n  }\n\n  @Override\n  public IMetaStoreElement getElement( String namespace, IMetaStoreElementType elementType, String elementId ) throws MetaStoreException {\n    try {\n      RowMetaAndData elementRow = delegate.getElement( new LongObjectId( new StringObjectId( elementId ) ) );\n      if ( elementRow == null ) {\n        return null;\n      }\n      return delegate.parseElement( elementType, elementRow );\n    } catch ( Exception e ) {\n      throw new MetaStoreException( \"Unable to get element\", e );\n    }\n  }\n\n  @Override\n  public IMetaStoreElement getElementByName( String namespace, IMetaStoreElementType elementType, String name ) throws MetaStoreException {\n    try {\n      LongObjectId namespaceId = delegate.getNamespaceId( namespace );\n      if ( namespaceId == null ) {\n        return null;\n      }\n      LongObjectId elementTypeId = delegate.getElementTypeId( namespaceId, elementType.getName() );\n      if ( elementTypeId == null ) {\n        return null;\n      }\n      LongObjectId elementId = delegate.getElementId( elementTypeId, name );\n      if ( elementId == null ) {\n        return null;\n      }","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KettleDatabaseRepositoryMetaStore.java#L315-L351","documentation":"Generic wrapper thrown by getElement when fetching a single element by id fails with an unexpected exception. A missing element returns null (the null check precedes parsing), so this error means the lookup itself failed — repository query error, invalid id conversion, or parse failure. The cause exception holds the details.","triggerScenarios":"Calling getElement(namespace, elementType, elementId) where new LongObjectId(new StringObjectId(elementId)) conversion or delegate.getElement/parseElement throws — e.g. elementId is not a valid ObjectId string or the repository query fails.","commonSituations":"Passing an element name instead of its id string; id from another repository/namespace; truncated id in stored configuration; JDBC connectivity failure.","solutions":["Validate elementId is a valid ObjectId string taken from getElementIds(namespace, elementType).","Inspect e.getCause() for the underlying database or conversion error and fix it.","Confirm the id was issued by the same repository you are connected to.","Handle null returns for genuinely missing ids instead of treating exceptions as not-found."],"exampleFix":"// before\nIMetaStoreElement el = metastore.getElement(namespace, type, elementName); // name as id\n\n// after\nString id = metastore.getElementIds(namespace, type).stream()\n  .filter(i -> name.equals(metastore.getElement(namespace, type, i).getName()))\n  .findFirst().orElse(null);\nIMetaStoreElement el = id == null ? null : metastore.getElement(namespace, type, id);","handlingStrategy":"validation","validationCode":"if (elementId == null || !metastore.getElementIds(namespace, elementType).contains(elementId)) {\n  return null;\n}","typeGuard":null,"tryCatchPattern":"try {\n  return metastore.getElement(namespace, elementType, elementId);\n} catch (MetaStoreException e) {\n  throw new IllegalArgumentException(\"Invalid element id or repository failure: \" + e.getCause(), e);\n}","preventionTips":["Pass ids from getElementIds, never element names","Handle null as not-found instead of catching","Keep full ObjectId strings intact in configuration"],"tags":["metastore","lookup","object-id","elements"],"backgroundTag":"invalid-identifier-format","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"}