{"record":{"id":"aa362d55b21e2fa4","repo":"pentaho/pentaho-kettle","slug":"failed-to-save-object-to-repository-object-name-already-aa362d","errorCode":null,"errorMessage":"Failed to save object to repository. Object [name] already exists.","messagePattern":"Failed to save object to repository\\. Object \\[name\\] already exists\\.","errorType":"exception","errorClass":"KettleObjectExistsException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryPartitionSchemaDelegate.java","lineNumber":93,"sourceCode":"      partitionSchema.setObjectId( getPartitionSchemaID( partitionSchema.getName() ) );\n    }\n\n    if ( partitionSchema.getObjectId() == null ) {\n      // New Slave Server\n      partitionSchema.setObjectId( insertPartitionSchema( partitionSchema ) );\n    } else {\n      ObjectId existingPartitionSchemaId = partitionSchema.getObjectId();\n\n      // If we received a partitionSchemaId and it is different from the partition schema we are working with...\n      if ( existingPartitionSchemaId != null && !partitionSchema.getObjectId().equals( existingPartitionSchemaId ) ) {\n        // A partition with this name already exists\n        if ( overwrite ) {\n          // Proceed with save, removing the original version from the repository first\n          repository.deletePartitionSchema( existingPartitionSchemaId );\n          updatePartitionSchema( partitionSchema );\n          repository.delPartitions( partitionSchema.getObjectId() );\n        } else {\n          throw new KettleObjectExistsException( \"Failed to save object to repository. Object [\"\n            + partitionSchema.getName() + \"] already exists.\" );\n        }\n      } else {\n        // There are no naming collisions (either it is the same object or the name is unique)\n        updatePartitionSchema( partitionSchema );\n        repository.delPartitions( partitionSchema.getObjectId() );\n      }\n    }\n\n    // Save the partitionschema-partition relationships\n    //\n    for ( int i = 0; i < partitionSchema.getPartitionIDs().size(); i++ ) {\n      insertPartition( partitionSchema.getObjectId(), partitionSchema.getPartitionIDs().get( i ) );\n    }\n\n    // Save a link to the transformation to keep track of the use of this partition schema\n    // Otherwise, we shouldn't bother with this\n    //","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryPartitionSchemaDelegate.java#L75-L111","documentation":"savePartitionSchema throws KettleObjectExistsException when a partition schema with the same name already exists in the repository and overwrite=false. The delegate refuses to silently clobber the existing object; callers must explicitly opt into overwriting.","triggerScenarios":"Calling savePartitionSchema(partitionSchema, overwrite=false) where getPartitionSchemaID(name) finds an existing R_PARTITION_SCHEMA row with the same name that isn't the same object.","commonSituations":"Importing transformations that define a partition schema name that already exists in the repository; two teams independently creating identically named schemas; re-running an import without the overwrite flag.","solutions":["Pass overwrite=true to replace the existing partition schema","Rename the partition schema to a unique name before saving","Check the existing schema first via getPartitionSchemaID and merge changes instead of duplicating","Catch KettleObjectExistsException and surface a clear UI message to the user"],"exampleFix":"// before\nObjectId id = delegate.savePartitionSchema(schema, false);\n// after\nObjectId id;\ntry {\n  id = delegate.savePartitionSchema(schema, false);\n} catch (KettleObjectExistsException e) {\n  id = delegate.savePartitionSchema(schema, true); // intentional overwrite\n}","handlingStrategy":"try-catch","validationCode":"ObjectId existing = delegate.getPartitionSchemaID(schema.getName());\nboolean willCollide = existing != null && !existing.equals(schema.getObjectId());","typeGuard":null,"tryCatchPattern":"try { delegate.savePartitionSchema(schema, false); } catch (KettleObjectExistsException e) { /* prompt user or pass overwrite=true */ }","preventionTips":["Check getPartitionSchemaID(name) before saving with overwrite=false","Use overwrite=true deliberately in import/CI pipelines","Adopt naming conventions to avoid cross-team collisions","Catch KettleObjectExistsException explicitly rather than generic KettleException"],"tags":["repository","duplicate","partition-schema","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"}