pentaho/pentaho-kettle · error · KettleException

We can't save the element with type

Error message

We can't save the element with type [{repositoryElementType}] in the repository

What it means

KettleDatabaseRepository.save has a switch over the element's RepositoryElementType; any element type without a case (i.e. not a transformation, job, or supported shared object) falls into the default and throws this KettleException. The database repository can only persist element types it has save delegates for.

Solutions

  1. Only pass supported elements (TransMeta, JobMeta, DatabaseMeta, SlaveServer, ClusterSchema, PartitionSchema, etc.) to save().
  2. Persist custom elements via the appropriate specific save method (e.g. saveDatabaseElement) instead of generic save().
  3. Add a case to the switch / extend the repository for custom element types if you own the fork.
  4. Check the element's getRepositoryElementType() before saving and handle unsupported types explicitly.

Example fix

// before
repo.save(customElement, "comment", null, true); // unsupported type
// after
if (customElement.getRepositoryElementType() == RepositoryObjectType.TRANSFORMATION) {
  repo.save(customElement, "comment", null, true);
} else {
  throw new IllegalArgumentException("Unsupported element type for repo.save");
}
Defensive patterns

Strategy: type-guard

Validate before calling

Set<RepositoryObjectType> savable = Set.of(RepositoryObjectType.TRANSFORMATION,
    RepositoryObjectType.JOB, RepositoryObjectType.DATABASE /* + shared objects */);
if (!savable.contains(element.getRepositoryElementType())) {
  throw new IllegalArgumentException("Element type not supported by repo.save");
}

Type guard

boolean savable(IRepositoryElement el) {
  RepositoryElementType t = el.getRepositoryElementType();
  return t == RepositoryElementType.TRANSFORMATION || t == RepositoryElementType.JOB
    || t == RepositoryElementType.DATABASE || t == RepositoryElementType.PARTITION_SCHEMA
    || t == RepositoryElementType.CLUSTER_SCHEMA || t == RepositoryElementType.SLAVE_SERVER;
}

Try / catch

try {
  repo.save(element, comment, null, overwrite);
} catch (KettleException e) {
  if (e.getMessage() != null && e.getMessage().contains("can't save the element with type")) {
    // fall back to type-specific persistence or reject
  } else { throw e; }
}

Prevention

When it happens

Trigger: Calling repo.save(repositoryElement, ...) with an element whose getRepositoryElementType() is not handled, e.g. a custom IRepositoryElement implementation or an unsupported object kind.

Common situations: Custom plugins embedding their own repository elements into the database repository; generic save utilities iterating heterogeneous element lists; API misuse after refactoring.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/repository/kdr/KettleDatabaseRepository.java:489

          securityProvider.validateAction( RepositoryOperation.MODIFY_DATABASE );
          databaseDelegate.saveDatabaseMeta( (DatabaseMeta) repositoryElement );
          break;
        case SLAVE_SERVER:
          securityProvider.validateAction( RepositoryOperation.MODIFY_SLAVE_SERVER );
          slaveServerDelegate.saveSlaveServer( (SlaveServer) repositoryElement, parentId, used, overwrite );
          break;
        case CLUSTER_SCHEMA:
          securityProvider.validateAction( RepositoryOperation.MODIFY_CLUSTER_SCHEMA );
          clusterSchemaDelegate.saveClusterSchema(
            (ClusterSchema) repositoryElement, versionComment, parentId, used, overwrite );
          break;
        case PARTITION_SCHEMA:
          securityProvider.validateAction( RepositoryOperation.MODIFY_PARTITION_SCHEMA );
          partitionSchemaDelegate.savePartitionSchema(
            (PartitionSchema) repositoryElement, parentId, used, overwrite );
          break;
        default:
          throw new KettleException( "We can't save the element with type ["
            + repositoryElement.getRepositoryElementType() + "] in the repository" );
      }

      // Automatically commit changes to these elements.
      //
      commit();
    } finally {
      unlockRepository();
    }
  }

  @Override
  public void save( RepositoryElementInterface repositoryElement, String versionComment, Calendar versionDate,
    ProgressMonitorListener monitor, boolean overwrite ) throws KettleException {
    save( repositoryElement, versionComment, monitor, null, false, overwrite );
  }

  // Condition

View on GitHub (pinned to f3058517a1)