{"record":{"id":"39606d856513bc15","repo":"pentaho/pentaho-kettle","slug":"failed-to-save-object-to-repository-object-name-already","errorCode":null,"errorMessage":"Failed to save object to repository. Object [{name}] already exists.","messagePattern":"Failed to save object to repository\\. Object \\[(.+?)\\] already exists\\.","errorType":"exception","errorClass":"KettleObjectExistsException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryClusterSchemaDelegate.java","lineNumber":116,"sourceCode":"    ObjectId existingClusterSchemaId = getClusterID( clusterSchema.getName() );\n    if ( existingClusterSchemaId != null ) {\n      clusterSchema.setObjectId( existingClusterSchemaId );\n    }\n\n    if ( clusterSchema.getObjectId() == null ) {\n      // New Slave Server\n      clusterSchema.setObjectId( insertCluster( clusterSchema ) );\n    } else {\n\n      // If we received a clusterSchemaId and it is different from the cluster schema we are working with...\n      if ( existingClusterSchemaId != null && !clusterSchema.getObjectId().equals( existingClusterSchemaId ) ) {\n        // A cluster with this name already exists\n        if ( overwrite ) {\n          // Proceed with save, removing the original version from the repository first\n          repository.deleteClusterSchema( existingClusterSchemaId );\n          updateCluster( clusterSchema );\n        } else {\n          throw new KettleObjectExistsException( \"Failed to save object to repository. Object [\"\n            + clusterSchema.getName() + \"] already exists.\" );\n        }\n      } else {\n        // There are no naming collisions (either it is the same object or the name is unique)\n        updateCluster( clusterSchema );\n      }\n    }\n\n    repository.delClusterSlaves( clusterSchema.getObjectId() );\n\n    // Also save the used slave server references.\n    for ( int i = 0; i < clusterSchema.getSlaveServers().size(); i++ ) {\n      SlaveServer slaveServer = clusterSchema.getSlaveServers().get( i );\n      if ( slaveServer.getObjectId() == null ) {\n        // oops, not yet saved!\n\n        repository.save( slaveServer, versionComment, null, id_transformation, isUsedByTransformation, overwrite );\n      }","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryClusterSchemaDelegate.java#L98-L134","documentation":"KettleObjectExistsException thrown by saveClusterSchema when saving a cluster schema whose name collides with an existing repository object and overwrite=false. The delegate finds an existing cluster schema id under the same name; without overwrite permission it refuses to save. Passing overwrite=true would delete the old version and save the new one.","triggerScenarios":"repository.save(clusterSchema, versionLabel, date) resolving to saveClusterSchema(overwrite=false) while getClusterSchemaID(name) returns a non-null id for a different object with the same name.","commonSituations":"Importing transformations/jobs whose cluster schema names already exist in the target repository without enabling the import 'overwrite' option.","solutions":["Call save with overwrite=true to replace the existing cluster schema","Rename the cluster schema before saving to avoid the collision","Delete the existing cluster schema explicitly via repository.deleteClusterSchema(existingId) first","Catch KettleObjectExistsException and prompt the user for overwrite/rename"],"exampleFix":"// before\nrepository.save(clusterSchema, \"Version\", new Date(), false); // throws if name exists\n\n// after\nrepository.save(clusterSchema, \"Version\", new Date(), true); // overwrite existing","handlingStrategy":"validation","validationCode":"ObjectId existing = repository.getClusterSchemaID(clusterSchema.getName()); if (existing != null && !overwriteAllowed) { throw new IllegalStateException(\"Cluster schema name in use: \" + clusterSchema.getName()); }","typeGuard":"boolean nameInUse = repository.getClusterSchemaID(name) != null;","tryCatchPattern":"try { repository.save(clusterSchema, label, date, false); } catch (KettleObjectExistsException e) { /* prompt user: overwrite or rename */ }","preventionTips":["Check name uniqueness before saving","Enable overwrite intentionally only when replacement is desired","Adopt naming conventions to reduce collisions","Catch KettleObjectExistsException during imports and offer merge options"],"tags":["repository","cluster-schema","duplicate-name"],"backgroundTag":"file-already-exists","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"}