pentaho/pentaho-kettle · error · MetaStoreDependenciesExistsException

Can't delete element type with name

Error message

Can't delete element type with name '${elementType.name}' because it is not empty

What it means

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.

Solutions

  1. Delete all elements of the type first (iterate getElements) then delete the type
  2. Inspect ids from MetaStoreDependenciesExistsException to identify blocking elements
  3. Recreate the type under a new name if you only want a fresh start

Example fix

// before
metaStore.deleteElementType( ns, elementType );
// after
for ( IMetaStoreElement el : metaStore.getElements( ns, elementType ) ) {
  metaStore.deleteElement( ns, elementType, el.getId() );
}
metaStore.deleteElementType( ns, elementType );
Defensive patterns

Strategy: validation

Validate before calling

if ( metaStore.getElements( ns, elementType ).length > 0 ) {
  throw new IllegalStateException( "Element type still has elements" );
}

Try / catch

try { metaStore.deleteElementType( ns, t ); } catch ( MetaStoreDependenciesExistsException e ) { logError( "Blocked by element ids: " + e.getDependencies(), e ); }

Prevention

When it happens

Trigger: Calling deleteElementType(namespace, elementType) while elements of that type still exist in the repository folder for the type.

Common situations: Trying to remove a plugin's element type before uninstalling its stored elements; leftover elements after partial deletes.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/b09170acb3258f21. Report an issue: GitHub.

Appendix: source

Thrown at plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/metastore/PurRepositoryMetaStore.java:266

    }

    return ids;
  }

  @Override
  public void deleteElementType( String namespace, IMetaStoreElementType elementType ) throws MetaStoreException {

    RepositoryFile namespaceRepositoryFile = validateNamespace( namespace );

    RepositoryFile elementTypeFile = findChildByName( namespaceRepositoryFile.getId(), elementType.getName() );
    List<RepositoryFile> children = getChildren( elementTypeFile.getId() );
    removeHiddenFilesFromList( children );

    if ( children.isEmpty() ) {
      pur.deleteFile( elementTypeFile.getId(), true, null );
    } else {
      List<String> ids = getElementIds( namespace, elementType );
      throw new MetaStoreDependenciesExistsException( ids, "Can't delete element type with name '"
          + elementType.getName() + "' because it is not empty" );
    }
  }

  protected void removeHiddenFilesFromList( List<RepositoryFile> children ) {

    for ( Iterator<RepositoryFile> it = children.iterator(); it.hasNext(); ) {
      RepositoryFile child = it.next();
      if ( child.isHidden() ) {
        it.remove();
      }
    }

  }

  // The elements

  public void createElement( String namespace, IMetaStoreElementType elementType, IMetaStoreElement element )

View on GitHub (pinned to f3058517a1)