{"record":{"id":"971b9e2be6b472a4","repo":"pentaho/pentaho-kettle","slug":"the-namespace-to-delete-namespace-is-not-empty-971b9e","errorCode":null,"errorMessage":"The namespace to delete, '<namespace>' is not empty","messagePattern":"The namespace to delete, '<namespace>' is not empty","errorType":"exception","errorClass":"MetaStoreDependenciesExistsException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KettleDatabaseRepositoryMetaStore.java","lineNumber":279,"sourceCode":"      repository.rollback();\n      throw new MetaStoreException( \"Unable to update element type\", e );\n    }\n  }\n\n  @Override\n  public void deleteElementType( String namespace, IMetaStoreElementType elementType ) throws MetaStoreException,\n    MetaStoreDependenciesExistsException {\n    try {\n      Collection<RowMetaAndData> elementTypeRows =\n        delegate.getElements( new LongObjectId( new StringObjectId( elementType.getId() ) ) );\n      if ( !elementTypeRows.isEmpty() ) {\n        List<String> dependencies = new ArrayList<String>();\n        for ( RowMetaAndData elementTypeRow : elementTypeRows ) {\n          Long elementTypeId =\n            elementTypeRow.getInteger( KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE );\n          dependencies.add( Long.toString( elementTypeId ) );\n        }\n        throw new MetaStoreDependenciesExistsException( dependencies, \"The namespace to delete, '\"\n          + namespace + \"' is not empty\" );\n      }\n\n      delegate.deleteElementType( new LongObjectId( new StringObjectId( elementType.getId() ) ) );\n      repository.commit();\n    } catch ( MetaStoreDependenciesExistsException e ) {\n      throw e;\n    } catch ( Exception e ) {\n      repository.rollback();\n      throw new MetaStoreException( e );\n    }\n  }\n\n  @Override\n  public List<IMetaStoreElement> getElements( String namespace, IMetaStoreElementType elementType ) throws MetaStoreException {\n    try {\n      IMetaStoreElementType type = getElementTypeByName( namespace, elementType.getName() );\n      if ( type == null ) {","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KettleDatabaseRepositoryMetaStore.java#L261-L297","documentation":"Thrown as MetaStoreDependenciesExistsException by deleteElementType when the namespace still contains other element types, so deleting this one is blocked. The exception lists the ids of dependent element types found in the namespace. The metastore refuses the deletion to avoid orphaning dependent types/elements.","triggerScenarios":"Calling deleteElementType(namespace, elementType) when the delegate's element-type query for the namespace returns rows other than the type being deleted — i.e. sibling element types (with their elements) still exist in the namespace.","commonSituations":"Deleting a namespace-scoped type while other types (e.g. both connection and field types of a plugin) share the namespace; attempting cleanup of a plugin's metastore data before removing all its types.","solutions":["Read getDependencies() from the exception, delete each dependent element type (and its elements) first.","Delete all remaining elements of the namespace before deleting element types.","Iterate getElementTypes(namespace) and remove all types, then delete the target/namespace.","If this is really a namespace removal, use deleteNamespace after emptying it instead."],"exampleFix":"// before\nmetastore.deleteElementType(namespace, elementType); // blocked\n\n// after\ntry {\n  metastore.deleteElementType(namespace, elementType);\n} catch (MetaStoreDependenciesExistsException e) {\n  for (String depId : e.getDependencies()) {\n    IMetaStoreElementType dep = metastore.getElementType(namespace, depId);\n    for (IMetaStoreElement el : metastore.getElements(namespace, dep)) {\n      metastore.deleteElement(namespace, dep, el.getId());\n    }\n    metastore.deleteElementType(namespace, dep);\n  }\n}","handlingStrategy":"try-catch","validationCode":"List<IMetaStoreElementType> siblings = metastore.getElementTypes(namespace);\nif (siblings.size() > 1) {\n  throw new IllegalStateException(\"Namespace not empty; delete other types first\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  metastore.deleteElementType(namespace, elementType);\n} catch (MetaStoreDependenciesExistsException e) {\n  for (String depId : e.getDependencies()) {\n    // recursively remove dependent types/elements\n  }\n}","preventionTips":["Inspect getDependencies() and delete dependents first","Empty namespaces fully before teardown","Encapsulate cascading deletion in a helper routine"],"tags":["metastore","delete","dependencies","namespace"],"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"}