{"record":{"id":"05fd41008f3a4632","repo":"pentaho/pentaho-kettle","slug":"failed-to-save-object-to-repository-object-0-already-exists","errorCode":null,"errorMessage":"Failed to save object to repository. Object [{0}] 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/KettleDatabaseRepositorySlaveServerDelegate.java","lineNumber":87,"sourceCode":"      // See if the slave doesn't exist already (just for safety and PDI-5102\n      //\n      slaveServer.setObjectId( getSlaveID( slaveServer.getName() ) );\n    }\n\n    if ( slaveServer.getObjectId() == null ) {\n      // New Slave Server\n      slaveServer.setObjectId( insertSlave( slaveServer ) );\n    } else {\n      ObjectId existingSlaveId = slaveServer.getObjectId();\n      if ( existingSlaveId != null\n        && slaveServer.getObjectId() != null && !slaveServer.getObjectId().equals( existingSlaveId ) ) {\n        // A slave with this name already exists\n        if ( overwrite ) {\n          // Proceed with save, removing the original version from the repository first\n          repository.deleteSlave( existingSlaveId );\n          updateSlave( slaveServer );\n        } else {\n          throw new KettleObjectExistsException( \"Failed to save object to repository. Object [\"\n            + slaveServer.getName() + \"] already exists.\" );\n        }\n      } else {\n        // There are no naming collisions (either it is the same object or the name is unique)\n        updateSlave( slaveServer );\n      }\n    }\n\n    // Save the trans-slave relationship too.\n    if ( id_transformation != null && isUsedByTransformation ) {\n      repository.insertTransformationSlave( id_transformation, slaveServer.getObjectId() );\n    }\n  }\n\n  public SlaveServer loadSlaveServer( ObjectId id_slave_server ) throws KettleException {\n    SlaveServer slaveServer = new SlaveServer();\n\n    slaveServer.setObjectId( id_slave_server );","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositorySlaveServerDelegate.java#L69-L105","documentation":"saveSlaveServer throws KettleObjectExistsException when a slave server with the same name already exists in the repository and overwrite=false. The delegate will not replace the existing R_SLAVE row unless the caller explicitly allows overwriting.","triggerScenarios":"Calling saveSlaveServer(slaveServer, overwrite=false) when getSlaveID(name) finds an existing slave row with the same name (and it is not the same object).","commonSituations":"Importing cluster definitions that collide with existing slave names; renaming clusters in one environment then importing into another; re-running setup scripts without overwrite.","solutions":["Pass overwrite=true to replace the existing slave server definition","Rename the slave server to a unique name","Look up the existing slave first and update its properties instead of creating a duplicate","Catch KettleObjectExistsException and prompt the user whether to overwrite"],"exampleFix":"// before\nObjectId id = delegate.saveSlaveServer(slave, false);\n// after\nObjectId id;\ntry {\n  id = delegate.saveSlaveServer(slave, false);\n} catch (KettleObjectExistsException e) {\n  id = delegate.saveSlaveServer(slave, true);\n}","handlingStrategy":"try-catch","validationCode":"ObjectId existing = delegate.getSlaveID(slave.getName());\nboolean willCollide = existing != null && !existing.equals(slave.getObjectId());","typeGuard":null,"tryCatchPattern":"try { delegate.saveSlaveServer(slave, false); } catch (KettleObjectExistsException e) { delegate.saveSlaveServer(slave, true); }","preventionTips":["Check getSlaveID(name) before saving with overwrite=false","Use overwrite=true in automated imports where clobbering is intended","Keep slave names unique per environment with a naming convention","Catch KettleObjectExistsException specifically"],"tags":["repository","duplicate","slave-server","conflict"],"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"}