pentaho/pentaho-kettle · error · MetaStoreDependenciesExistsException

The namespace to delete

Error message

The namespace to delete, '<namespace>' is not empty

What it means

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.

Solutions

  1. Read getDependencies() from the exception, delete each dependent element type (and its elements) first.
  2. Delete all remaining elements of the namespace before deleting element types.
  3. Iterate getElementTypes(namespace) and remove all types, then delete the target/namespace.
  4. If this is really a namespace removal, use deleteNamespace after emptying it instead.

Example fix

// before
metastore.deleteElementType(namespace, elementType); // blocked

// after
try {
  metastore.deleteElementType(namespace, elementType);
} catch (MetaStoreDependenciesExistsException e) {
  for (String depId : e.getDependencies()) {
    IMetaStoreElementType dep = metastore.getElementType(namespace, depId);
    for (IMetaStoreElement el : metastore.getElements(namespace, dep)) {
      metastore.deleteElement(namespace, dep, el.getId());
    }
    metastore.deleteElementType(namespace, dep);
  }
}
Defensive patterns

Strategy: try-catch

Validate before calling

List<IMetaStoreElementType> siblings = metastore.getElementTypes(namespace);
if (siblings.size() > 1) {
  throw new IllegalStateException("Namespace not empty; delete other types first");
}

Try / catch

try {
  metastore.deleteElementType(namespace, elementType);
} catch (MetaStoreDependenciesExistsException e) {
  for (String depId : e.getDependencies()) {
    // recursively remove dependent types/elements
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KettleDatabaseRepositoryMetaStore.java:279

      repository.rollback();
      throw new MetaStoreException( "Unable to update element type", e );
    }
  }

  @Override
  public void deleteElementType( String namespace, IMetaStoreElementType elementType ) throws MetaStoreException,
    MetaStoreDependenciesExistsException {
    try {
      Collection<RowMetaAndData> elementTypeRows =
        delegate.getElements( new LongObjectId( new StringObjectId( elementType.getId() ) ) );
      if ( !elementTypeRows.isEmpty() ) {
        List<String> dependencies = new ArrayList<String>();
        for ( RowMetaAndData elementTypeRow : elementTypeRows ) {
          Long elementTypeId =
            elementTypeRow.getInteger( KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE );
          dependencies.add( Long.toString( elementTypeId ) );
        }
        throw new MetaStoreDependenciesExistsException( dependencies, "The namespace to delete, '"
          + namespace + "' is not empty" );
      }

      delegate.deleteElementType( new LongObjectId( new StringObjectId( elementType.getId() ) ) );
      repository.commit();
    } catch ( MetaStoreDependenciesExistsException e ) {
      throw e;
    } catch ( Exception e ) {
      repository.rollback();
      throw new MetaStoreException( e );
    }
  }

  @Override
  public List<IMetaStoreElement> getElements( String namespace, IMetaStoreElementType elementType ) throws MetaStoreException {
    try {
      IMetaStoreElementType type = getElementTypeByName( namespace, elementType.getName() );
      if ( type == null ) {

View on GitHub (pinned to f3058517a1)