{"record":{"id":"024d9569157c49df","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-element-by-name-name-from-namespace-namespace","errorCode":null,"errorMessage":"Unable to get element by name '<name>' from namespace '<namespace>'","messagePattern":"Unable to get element by name '<name>' from namespace '<namespace>'","errorType":"exception","errorClass":"MetaStoreException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KettleDatabaseRepositoryMetaStore.java","lineNumber":359,"sourceCode":"      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      }\n      RowMetaAndData elementRow = delegate.getElement( elementId );\n      if ( elementRow == null ) {\n        return null;\n      }\n\n      return delegate.parseElement( elementType, elementRow );\n    } catch ( Exception e ) {\n      throw new MetaStoreException( \"Unable to get element by name '\"\n        + name + \"' from namespace '\" + namespace + \"'\", e );\n    }\n  }\n\n  @Override\n  public void createElement( String namespace, IMetaStoreElementType elementType, IMetaStoreElement element ) throws MetaStoreException, MetaStoreElementExistException {\n    try {\n      IMetaStoreElement found = getElementByName( namespace, elementType, element.getName() );\n      if ( found != null ) {\n        throw new MetaStoreElementExistException( Arrays.asList( found ), \"The element with name '\"\n          + element.getName() + \"' already exists\" );\n      }\n\n      delegate.insertElement( elementType, element );\n      repository.commit();\n    } catch ( MetaStoreElementExistException e ) {\n      throw e;\n    } catch ( Exception e ) {","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KettleDatabaseRepositoryMetaStore.java#L341-L377","documentation":"Wrapper thrown by getElementByName when resolving an element by name within a namespace and element type fails with an unexpected exception. The flow verifies the namespace, resolves the type, queries the element id by name, and parses the row; any delegate failure is wrapped in MetaStoreException. A name that does not exist returns null rather than throwing.","triggerScenarios":"Calling getElementByName(namespace, elementType, name) where the namespace verification, id-by-name query, or delegate.parseElement throws — repository connection failure, malformed elementType, or unparseable rows.","commonSituations":"Database outage during element lookup; elementType object from a stale/other namespace so resolution fails; corrupted element rows after interrupted writes; concurrent deletion between id lookup and parse.","solutions":["Check e.getCause() for the JDBC failure; restore connectivity and retry.","Reload elementType via getElementTypeByName(namespace, typeName) to ensure a fresh, valid id.","Verify the namespace exists before lookup to narrow the failure source.","Treat null (not an exception) as not-found; repair corrupted repository tables if parse errors persist."],"exampleFix":"// before\nIMetaStoreElement el = metastore.getElementByName(namespace, type, name); // may throw\n\n// after\ntry {\n  IMetaStoreElement el = metastore.getElementByName(namespace, type, name);\n} catch (MetaStoreException e) {\n  log.error(\"Lookup failed for '\" + name + \"': \" + e.getCause(), e);\n}","handlingStrategy":"try-catch","validationCode":"if (elementType.getId() == null) {\n  elementType = metastore.getElementTypeByName(namespace, elementType.getName());\n  if (elementType == null) return null;\n}","typeGuard":null,"tryCatchPattern":"try {\n  return metastore.getElementByName(namespace, elementType, name);\n} catch (MetaStoreException e) {\n  log.error(\"Element lookup failed for '{}': {}\", name, e.getCause(), e);\n  return null;\n}","preventionTips":["Reload element types before repeated lookups","Distinguish null (miss) from exception (repository failure)","Retry lookups after connectivity restoration"],"tags":["metastore","lookup","elements","database"],"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"}