{"record":{"id":"2d14fc959a685ea6","repo":"pentaho/pentaho-kettle","slug":"unable-to-create-element-with-name-of-type","errorCode":null,"errorMessage":"Unable to create element with name '{}' of type '{}'","messagePattern":"Unable to create element with name '(.+?)' of type '(.+?)'","errorType":"exception","errorClass":"MetaStoreException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KettleDatabaseRepositoryMetaStore.java","lineNumber":379,"sourceCode":"    }\n  }\n\n  @Override\n  public void createElement( String namespace, IMetaStoreElementType elementType, IMetaStoreElement element ) throws MetaStoreException, MetaStoreElementExistException {\n    try {\n      IMetaStoreElement found = getElementByName( namespace, elementType, element.getName() );\n      if ( found != null ) {\n        throw new MetaStoreElementExistException( Arrays.asList( found ), \"The element with name '\"\n          + element.getName() + \"' already exists\" );\n      }\n\n      delegate.insertElement( elementType, element );\n      repository.commit();\n    } catch ( MetaStoreElementExistException e ) {\n      throw e;\n    } catch ( Exception e ) {\n      repository.rollback();\n      throw new MetaStoreException( \"Unable to create element with name '\"\n        + element.getName() + \"' of type '\" + elementType.getName() + \"'\", e );\n    }\n  }\n\n  @Override\n  public void deleteElement( String namespace, IMetaStoreElementType elementType, String elementId ) throws MetaStoreException {\n    try {\n      IMetaStoreElementType type = getElementTypeByName( namespace, elementType.getName() );\n      if ( type == null ) {\n        throw new MetaStoreException( \"Unable to find element type with name '\" + elementType.getName() + \"'\" );\n      }\n\n      delegate.deleteElement( new LongObjectId( new StringObjectId( elementId ) ) );\n      repository.commit();\n    } catch ( Exception e ) {\n      repository.rollback();\n      throw new MetaStoreException( \"Unable to delete element with id '\"\n        + elementId + \"' of type '\" + elementType.getName() + \"'\", e );","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KettleDatabaseRepositoryMetaStore.java#L361-L397","documentation":"Generic MetaStoreException wrapper from createElement: any unexpected exception while inserting the element row into the repository database (other than the duplicate-name case) is re-thrown with this message, after repository.rollback(). The original cause is attached as the cause of the Kettle/MetaStore exception.","triggerScenarios":"delegate.insertElement fails (DB connection lost, constraint violation other than name, bad element structure/attributes), or repository.commit() throws; createElement then rolls back and wraps the cause.","commonSituations":"Repository database down or connection dropped mid-operation; element containing attribute values too large for the column; malformed element objects built programmatically; transaction deadlocks.","solutions":["Inspect the cause (e.getCause()) for the real database error and fix that root cause","Verify repository DB connectivity and credentials","Validate the element's properties/attributes are populated and within DB limits before insert","Retry the operation after a transient DB failure; the rollback leaves state clean"],"exampleFix":"// before\ntry { metastore.createElement(ns, type, element); } catch (MetaStoreException e) { throw e; }\n// after\ntry { metastore.createElement(ns, type, element); }\ncatch (MetaStoreException e) {\n  LOG.error(\"create failed, root cause:\", e.getCause());\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (element.getName() == null || element.getName().isEmpty()) {\n  throw new IllegalArgumentException(\"Element name required before insert\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  metastore.createElement(namespace, elementType, element);\n} catch (MetaStoreException e) {\n  Throwable root = e.getCause();\n  LOG.error(\"Element insert failed, cause: \" + (root == null ? \"none\" : root.getMessage()), e);\n  throw e;\n}","preventionTips":["Keep repository DB connection healthy before batch metastore operations","Log and inspect getCause() — this message is only a wrapper","Populate element attributes fully before insert","Retry transient DB failures; rollback leaves state clean"],"tags":["metastore","database","transaction","rollback"],"backgroundTag":"database-write-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}