pentaho/pentaho-kettle · error · MetaStoreException

Unable to delete element with id

Error message

Unable to delete element with id '{}' of type '{}'

What it means

Generic MetaStoreException wrapper from deleteElement: any failure after the type lookup — typically delegate.deleteElement on the given elementId or the subsequent commit — is wrapped with this message after repository.rollback(). The underlying cause is chained.

Solutions

  1. Verify the element exists (getElementById / getElementByName) before deleting
  2. Confirm the elementId belongs to the given elementType and namespace
  3. Check the cause for the real DB error and fix connectivity/constraint issues
  4. Re-run after rollback; the transaction leaves state unchanged

Example fix

// before
metastore.deleteElement(namespace, elementType, elementId);
// after
if (metastore.getElementById(namespace, elementType, elementId) != null) {
  metastore.deleteElement(namespace, elementType, elementId);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (metastore.getElementById(namespace, elementType, elementId) == null) {
  throw new IllegalStateException("Element not found: " + elementId);
}

Try / catch

try {
  metastore.deleteElement(namespace, elementType, elementId);
} catch (MetaStoreException e) {
  if (metastore.getElementById(namespace, elementType, elementId) == null) {
    // already gone; idempotent success
  } else throw e;
}

Prevention

When it happens

Trigger: delegate.deleteElement(new LongObjectId(new StringObjectId(elementId))) fails because the elementId does not exist, is malformed, or the DB write/commit throws; deleteElement also runs inside updateElement, so a bad elementId surfaces here.

Common situations: Deleting with an elementId from a different type/namespace; stale IDs after the element was already deleted; DB connectivity loss during the delete transaction.

Related errors


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

Appendix: source

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

      repository.rollback();
      throw new MetaStoreException( "Unable to create element with name '"
        + element.getName() + "' of type '" + elementType.getName() + "'", e );
    }
  }

  @Override
  public void deleteElement( String namespace, IMetaStoreElementType elementType, String elementId ) throws MetaStoreException {
    try {
      IMetaStoreElementType type = getElementTypeByName( namespace, elementType.getName() );
      if ( type == null ) {
        throw new MetaStoreException( "Unable to find element type with name '" + elementType.getName() + "'" );
      }

      delegate.deleteElement( new LongObjectId( new StringObjectId( elementId ) ) );
      repository.commit();
    } catch ( Exception e ) {
      repository.rollback();
      throw new MetaStoreException( "Unable to delete element with id '"
        + elementId + "' of type '" + elementType.getName() + "'", e );
    }
  }

  @Override
  public void updateElement( String namespace, IMetaStoreElementType elementType, String elementId,
    IMetaStoreElement element ) throws MetaStoreException {
    try {
      // This is a delete/insert operation
      //
      deleteElement( namespace, elementType, elementId );
      createElement( namespace, elementType, element );
      repository.commit();
    } catch ( Exception e ) {
      repository.rollback();
      throw new MetaStoreException( "Unable to update element with id '"
        + elementId + "' called '" + element.getName() + "' in type '" + elementType.getName() + "'", e );
    }

View on GitHub (pinned to f3058517a1)