{"record":{"id":"9c457d5bfd695407","repo":"pentaho/pentaho-kettle","slug":"unable-to-create-new-element-with-name-elementname","errorCode":null,"errorMessage":"Unable to create new element with name 'elementName'","messagePattern":"Unable to create new element with name 'elementName'","errorType":"exception","errorClass":"MetaStoreException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryMetaStoreDelegate.java","lineNumber":461,"sourceCode":"      repository.connectionDelegate.getDatabase().prepareInsert(\n        table.getRowMeta(), KettleDatabaseRepository.TABLE_R_ELEMENT );\n      repository.connectionDelegate.getDatabase().setValuesInsert( table );\n      repository.connectionDelegate.getDatabase().insertRow();\n      repository.connectionDelegate.getDatabase().closeInsert();\n\n      element.setId( elementId.toString() );\n\n      // Now save the attributes\n      //\n      insertAttributes( element.getChildren(), elementId, new LongObjectId( 0L ) );\n\n      if ( log.isDebug() ) {\n        log.logDebug( \"Saved element with name [\" + element.getName() + \"]\" );\n      }\n\n      return elementId;\n    } catch ( Exception e ) {\n      throw new MetaStoreException( \"Unable to create new element with name '\" + element.getName() + \"'\", e );\n    }\n  }\n\n  private void insertAttributes( List<IMetaStoreAttribute> children, LongObjectId elementId,\n    LongObjectId parentAttributeId ) throws Exception {\n    for ( IMetaStoreAttribute child : children ) {\n      LongObjectId attributeId =\n        repository.connectionDelegate.getNextID(\n          quoteTable( KettleDatabaseRepository.TABLE_R_ELEMENT_ATTRIBUTE ),\n          quote( KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE ) );\n      RowMetaAndData table = new RowMetaAndData();\n\n      table.addValue(\n        new ValueMetaInteger(\n          KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE ), attributeId.longValue() );\n      table.addValue(\n        new ValueMetaInteger(\n          KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT ),","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryMetaStoreDelegate.java#L443-L479","documentation":"This MetaStoreException is thrown by insertElement when any exception occurs while persisting a metastore element (and its attributes) into the Kettle database repository. The library wraps the underlying failure so callers get a consistent exception type, with the element name included for diagnosis and the original exception chained as the cause.","triggerScenarios":"Calling KettleDatabaseRepositoryMetaStoreDelegate.insertElement(element) when the underlying JDBC insert fails: e.g. repository database connection lost, R_ELEMENT/ R_ELEMENT_ATTRIBUTE tables missing or corrupted, name column too long, or insertAttributes throwing while writing children.","commonSituations":"Database down or network blip mid-save; repository schema not upgraded after a Pentaho version change; element name containing characters that break the stored column length; insufficient DB permissions on the metastore tables.","solutions":["Inspect the chained cause (e.getCause()) to find the real JDBC/database error and fix that first","Verify the repository database is reachable and the R_ELEMENT tables exist (run repository upgrade/repair)","Check DB user permissions to INSERT into the metastore tables","Shorten or sanitize the element name and retry"],"exampleFix":"// before\ntry { delegate.insertElement(element); } catch (MetaStoreException e) { log.error(e.getMessage()); }\n// after\ntry { delegate.insertElement(element); } catch (MetaStoreException e) {\n  Throwable cause = e.getCause();\n  log.error(\"Failed to create element \" + element.getName() + \": \" + (cause != null ? cause.getMessage() : e.getMessage()), e);\n  // fix root cause (connection/schema/permissions) then retry\n}","handlingStrategy":"try-catch","validationCode":"if (element == null || element.getName() == null || element.getName().isEmpty()) throw new IllegalArgumentException(\"Element name required before insertElement\");\n// also verify repository connection: if (!repository.isConnected()) reconnect();","typeGuard":"boolean isInsertable(org.pentaho.metastore.api.IMetaStoreElement e) { return e != null && e.getName() != null && !e.getName().isEmpty(); }","tryCatchPattern":"try { delegate.insertElement(element); } catch (MetaStoreException e) { Throwable c = e.getCause(); log.error(\"insertElement failed for '\" + element.getName() + \"': \" + (c != null ? c.getMessage() : \"\"), e); throw e; }","preventionTips":["Always inspect the chained cause of MetaStoreException — it carries the real DB error","Keep the repository schema upgraded to match your Pentaho version","Monitor DB connectivity before bulk metastore writes","Keep element names within the R_ELEMENT column length"],"tags":["database","metastore","repository","jdbc"],"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"}