pentaho/pentaho-kettle · error · KettleException
Destination directory already contains a diectory with…
Error message
Destination directory already contains a diectory with requested name
What it means
Thrown by renameDirectory when the destination parent already contains a child directory whose name matches the requested new name (or the current name when newName is null). The delegate loads the new parent and calls findChild(name) to enforce unique directory names within a parent. Thrown before any database write, so nothing is modified. (Note the message contains a typo: 'diectory'.)
Solutions
- Check the destination for an existing child with the target name and rename/skip first: newParent.findChild(name)
- Pick a unique newName (append a timestamp or counter) when a sibling conflict exists
- Guard scripts with idempotency checks before creating/renaming directories
- Handle the exception and surface a user-friendly 'name already in use' message
Example fix
// before
repo.renameRepositoryDirectory( dirId, newParent, "Archive" ); // fails if Archive exists
// after
if ( newParent.findChild( "Archive" ) == null ) {
repo.renameRepositoryDirectory( dirId, newParent, "Archive" );
} else {
repo.renameRepositoryDirectory( dirId, newParent, "Archive-" + System.currentTimeMillis() );
} Defensive patterns
Strategy: validation
Validate before calling
RepositoryDirectoryInterface dest = repo.findDirectory( "/destination" );
String target = newName != null ? newName : existingDir.getName();
if ( dest.findChild( target ) != null ) {
// choose a unique name or abort before calling the API
} Try / catch
try {
repo.renameRepositoryDirectory( id, newParent, newName );
} catch ( KettleException e ) {
if ( e.getMessage() != null && e.getMessage().contains( "already contains" ) ) {
// surface 'name already in use' and prompt for a different name
}
} Prevention
- Check findChild(targetName) on the destination before renaming
- Make bulk scripts idempotent: skip or rename on conflict
- Anticipate concurrent users creating the same folder name
- Use unique suffixes (timestamp/counter) for generated names
When it happens
Trigger: repository.renameRepositoryDirectory(id, newParent, newName) where newParent already has a child named newName; or a pure rename where a sibling of the same name exists (newName null, rd.getName() already present in parent).
Common situations: Re-running a migration/import script that already created the target folder on a previous run; two users renaming/creating the same folder concurrently; case-sensitivity assumptions when the DB compare is case-sensitive.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- Unable to rename the specified repository directory [id]
- A connection of type PALO is expected
- A connection of type PALO is expected
- A server socket allocation always has to accompanied by a…
- A server socket allocation always has to accompanied by…
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/673ddcc21bec8e1b.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryDirectoryDelegate.java:228
*/
public synchronized void renameDirectory( ObjectId id_directory, ObjectId id_directory_parent, String newName ) throws KettleException {
if ( id_directory.equals( id_directory_parent ) ) {
// Make sure the directory cannot become its own parent
throw new KettleException( "Failed to copy directory into itself" );
} else {
// Make sure the directory does not become a descendant of itself
RepositoryDirectory rd = new RepositoryDirectory();
loadRepositoryDirectory( rd, id_directory );
if ( rd.findDirectory( id_directory_parent ) != null ) {
// The parent directory is a child of this directory. Do not proceed
throw new KettleException( "Directory cannot become a child to itself" );
} else {
// Check for duplication
RepositoryDirectory newParent = new RepositoryDirectory();
loadRepositoryDirectory( newParent, id_directory_parent );
RepositoryDirectory child = newParent.findChild( newName == null ? rd.getName() : newName );
if ( child != null ) {
throw new KettleException( "Destination directory already contains a diectory with requested name" );
}
}
}
if ( id_directory_parent != null || newName != null ) {
RowMetaAndData r = new RowMetaAndData();
String sql = "UPDATE " + quoteTable( KettleDatabaseRepository.TABLE_R_DIRECTORY ) + " SET ";
boolean additionalParameter = false;
if ( newName != null ) {
additionalParameter = true;
sql += quote( KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME ) + " = ?";
r.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME ), newName );
}
if ( id_directory_parent != null ) {
// Add a parameter separator if the first parm was addedView on GitHub (pinned to f3058517a1)