{"record":{"id":"b09170acb3258f21","repo":"pentaho/pentaho-kettle","slug":"can-t-delete-element-type-with-name-elementtype-name-because","errorCode":null,"errorMessage":"Can't delete element type with name '${elementType.name}' because it is not empty","messagePattern":"Can't delete element type with name '(.+?)' because it is not empty","errorType":"exception","errorClass":"MetaStoreDependenciesExistsException","httpStatus":null,"severity":"error","filePath":"plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/metastore/PurRepositoryMetaStore.java","lineNumber":266,"sourceCode":"    }\n\n    return ids;\n  }\n\n  @Override\n  public void deleteElementType( String namespace, IMetaStoreElementType elementType ) throws MetaStoreException {\n\n    RepositoryFile namespaceRepositoryFile = validateNamespace( namespace );\n\n    RepositoryFile elementTypeFile = findChildByName( namespaceRepositoryFile.getId(), elementType.getName() );\n    List<RepositoryFile> children = getChildren( elementTypeFile.getId() );\n    removeHiddenFilesFromList( children );\n\n    if ( children.isEmpty() ) {\n      pur.deleteFile( elementTypeFile.getId(), true, null );\n    } else {\n      List<String> ids = getElementIds( namespace, elementType );\n      throw new MetaStoreDependenciesExistsException( ids, \"Can't delete element type with name '\"\n          + elementType.getName() + \"' because it is not empty\" );\n    }\n  }\n\n  protected void removeHiddenFilesFromList( List<RepositoryFile> children ) {\n\n    for ( Iterator<RepositoryFile> it = children.iterator(); it.hasNext(); ) {\n      RepositoryFile child = it.next();\n      if ( child.isHidden() ) {\n        it.remove();\n      }\n    }\n\n  }\n\n  // The elements\n\n  public void createElement( String namespace, IMetaStoreElementType elementType, IMetaStoreElement element )","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/metastore/PurRepositoryMetaStore.java#L248-L284","documentation":"Thrown by PurRepositoryMetaStore.deleteElementType() when the element-type folder still contains element files (after removing hidden files), so the delete would lose data. It is a MetaStoreDependenciesExistsException carrying the ids of contained elements.","triggerScenarios":"Calling deleteElementType(namespace, elementType) while elements of that type still exist in the repository folder for the type.","commonSituations":"Trying to remove a plugin's element type before uninstalling its stored elements; leftover elements after partial deletes.","solutions":["Delete all elements of the type first (iterate getElements) then delete the type","Inspect ids from MetaStoreDependenciesExistsException to identify blocking elements","Recreate the type under a new name if you only want a fresh start"],"exampleFix":"// before\nmetaStore.deleteElementType( ns, elementType );\n// after\nfor ( IMetaStoreElement el : metaStore.getElements( ns, elementType ) ) {\n  metaStore.deleteElement( ns, elementType, el.getId() );\n}\nmetaStore.deleteElementType( ns, elementType );","handlingStrategy":"validation","validationCode":"if ( metaStore.getElements( ns, elementType ).length > 0 ) {\n  throw new IllegalStateException( \"Element type still has elements\" );\n}","typeGuard":null,"tryCatchPattern":"try { metaStore.deleteElementType( ns, t ); } catch ( MetaStoreDependenciesExistsException e ) { logError( \"Blocked by element ids: \" + e.getDependencies(), e ); }","preventionTips":["Delete contained elements before deleting the type","Inspect dependency ids from the exception","Verify deletions completed before removing the type"],"tags":["metastore","element-type","dependencies"],"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"}