{"record":{"id":"1086f383fa830681","repo":"pentaho/pentaho-kettle","slug":"the-namespace-to-delete-namespace-is-not-empty","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":"warning","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KettleDatabaseRepositoryMetaStore.java","lineNumber":104,"sourceCode":"    } catch ( Exception e ) {\n      repository.rollback();\n      throw new MetaStoreException( e );\n    }\n  }\n\n  @Override\n  public void deleteNamespace( String namespace ) throws MetaStoreException, MetaStoreDependenciesExistsException {\n    try {\n      ObjectId namespaceId = delegate.verifyNamespace( namespace );\n\n      List<IMetaStoreElementType> elementTypes = getElementTypes( namespace );\n      if ( !elementTypes.isEmpty() ) {\n\n        List<String> dependencies = new ArrayList<String>();\n        for ( IMetaStoreElementType elementType : elementTypes ) {\n          dependencies.add( elementType.getId() );\n        }\n        throw new MetaStoreDependenciesExistsException( dependencies, \"The namespace to delete, '\"\n          + namespace + \"' is not empty\" );\n      }\n\n      // Now delete the namespace\n      //\n      delegate.deleteNamespace( namespaceId );\n      repository.commit();\n    } catch ( MetaStoreDependenciesExistsException e ) {\n      throw e;\n    } catch ( MetaStoreException e ) {\n      repository.rollback();\n      throw e;\n    } catch ( Exception e ) {\n      repository.rollback();\n      throw new MetaStoreException( \"Unable to delete namespace '\" + namespace + \"'\", e );\n    }\n  }\n","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KettleDatabaseRepositoryMetaStore.java#L86-L122","documentation":"deleteNamespace() refuses to remove a namespace that still contains element types. It collects the ids of remaining element types and throws MetaStoreDependenciesExistsException('The namespace to delete, X is not empty', dependencies). This protects dependent metadata from being orphaned.","triggerScenarios":"metastore.deleteNamespace(name) when getElementTypes(namespace) returns a non-empty list — the namespace still has element types defined in it.","commonSituations":"Trying to clean up a namespace that still holds shared metadata; deleting namespaces out of dependency order; leftovers from a previous application version.","solutions":["Delete all element types in the namespace first (list via getElementTypes, deleteElementType each), then delete the namespace","Inspect the exception's dependencies list to know exactly which element types block deletion","Move needed element types to another namespace before deleting"],"exampleFix":"// before\nmetaStore.deleteNamespace(\"old-ns\"); // throws if not empty\n// after\nfor (IMetaStoreElementType t : metaStore.getElementTypes(\"old-ns\")) {\n  metaStore.deleteElementType(\"old-ns\", t);\n}\nmetaStore.deleteNamespace(\"old-ns\");","handlingStrategy":"validation","validationCode":"List<IMetaStoreElementType> types = metaStore.getElementTypes(namespace);\nif (!types.isEmpty()) {\n  types.forEach(t -> { try { metaStore.deleteElementType(namespace, t); } catch (MetaStoreException e) { throw new RuntimeException(e); } });\n}","typeGuard":null,"tryCatchPattern":"try { metaStore.deleteNamespace(ns); } catch (MetaStoreDependenciesExistsException e) { e.getDependencies().forEach(id -> log(\"Blocked by element type: \" + id)); }","preventionTips":["Always drain child element types before deleting a namespace","Use the exception's dependencies list to drive cleanup","Adopt a delete-bottom-up order for metastore hierarchies"],"tags":["metastore","namespace","dependencies","delete"],"backgroundTag":"invalid-state-transition","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"}