pentaho/pentaho-kettle · error · MetaStoreDependenciesExistsException

Namespace ' can not be deleted because it is not empty

Error message

Namespace '${namespace} can not be deleted because it is not empty

What it means

Thrown by PurRepositoryMetaStore.deleteNamespace() when the namespace folder still contains children (element types or elements), so deleting it would orphan dependencies. It is a MetaStoreDependenciesExistsException carrying the ids of the blocking children.

Solutions

  1. Delete all element types and elements in the namespace first
  2. Inspect the child ids from MetaStoreDependenciesExistsException to find blockers
  3. Use the server UI to inspect and remove leftover folders under /etc/metastore/<ns>

Example fix

// before
metaStore.deleteNamespace( ns );
// after
for ( String typeId : metaStore.getElementTypeNames( ns ) ) {
  metaStore.deleteElementType( ns, metaStore.getElementTypeByName( ns, typeId ) );
}
metaStore.deleteNamespace( ns );
Defensive patterns

Strategy: validation

Validate before calling

if ( metaStore.getElementTypeNames( namespace ).length > 0 ) {
  throw new IllegalStateException( "Namespace not empty; delete types first" );
}

Try / catch

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

Prevention

When it happens

Trigger: Calling deleteNamespace(ns) while the namespace folder on the server still holds element-type folders or element files; hidden-file filtering doesn't empty the child list.

Common situations: Attempting a clean teardown of a namespace that still has element types; leftover server artifacts not visible in the PDI metastore explorer.

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/8f6954b07ef4399d. Report an issue: GitHub.

Appendix: source

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

  @Override
  public void deleteNamespace( String namespace ) throws MetaStoreException {
    RepositoryFile namespaceFile = getNamespaceRepositoryFile( namespace );
    if ( namespaceFile == null ) {
      return; // already gone.
    }
    List<RepositoryFile> children = getChildren( namespaceFile.getId() );
    if ( children == null || children.isEmpty() ) {
      // Delete the file, there are no children.
      //
      pur.deleteFile( namespaceFile.getId(), true, "Delete namespace" );
    } else {
      // Dependencies exists, throw an exception.
      //
      List<String> elementTypeIds = new ArrayList<String>();
      for ( RepositoryFile child : children ) {
        elementTypeIds.add( child.getId().toString() );
      }
      throw new MetaStoreDependenciesExistsException( elementTypeIds, "Namespace '" + namespace
          + " can not be deleted because it is not empty" );
    }
  }

  @Override
  public List<String> getNamespaces() throws MetaStoreException {
    List<String> namespaces = new ArrayList<String>();
    List<RepositoryFile> children = getChildren( namespacesFolder.getId() );
    for ( RepositoryFile child : children ) {
      namespaces.add( child.getName() );
    }
    return namespaces;
  }

  // The element types

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

View on GitHub (pinned to f3058517a1)