pentaho/pentaho-kettle · error · IllegalArgumentException
Sorry, can not rename on the fly while copying in the same…
Error message
Sorry, can not rename on the fly while copying in the same VFS Connection.
What it means
OverwriteAwareFileSelector implements an overwrite/skip/rename prompt flow while copying files through a VFS connection. When the user chooses 'Rename', the selector cannot honor it because renaming mid-copy on the same VFS connection is not supported, so it throws this IllegalArgumentException as an explicit unsupported-operation guard (the comment says 'should not happen').
Solutions
- Answer 'Overwrite' or 'Skip' instead of 'Rename' when the prompt appears during a same-VFS-connection copy
- Copy via two distinct VFS connections (or a local temp staging path) so rename-on-copy is available
- Rename the destination file before starting the copy so no duplicate prompt is raised
- Fix the calling code to never seed OverwriteStatus.isRename() when source and target share one connection
Example fix
// before
if ( overwriteStatus.isRename() ) {
throw new IllegalArgumentException(
"Sorry, can not rename on the fly while copying in the same VFS Connection." );
}
// after
if ( overwriteStatus.isRename() ) {
// rename the target first, then copy
FileObject dest = getFileObject( targetName + ".bak" );
dest.copyFrom( source, new AllFileSelector() );
return true;
} Defensive patterns
Strategy: validation
Validate before calling
if ( overwriteStatus != null && overwriteStatus.isRename() && sameVfsConnection( source, target ) ) {
throw new IllegalArgumentException( "Rename is not supported when copying within the same VFS connection" );
} Type guard
boolean renameAllowed = overwriteStatus != null && overwriteStatus.isRename() && !sameVfsConnection( source, target );
Prevention
- Do not seed rename into OverwriteStatus for same-connection copies
- Rename targets before initiating the copy
- Use separate VFS connections or a staging directory when rename-on-copy is needed
When it happens
Trigger: Called from includeFile or traverseDescendents when a file with a duplicate name is found and the stored OverwriteStatus has isRename()==true — i.e. a rename decision reached the same-connection copy path.
Common situations: Batch copy jobs over a single VFS connection where users answer 'Rename' to overwrite prompts; UI flows that set rename in OverwriteStatus for targets inside the same connection; programmatic use of the selector with pre-seeded rename statuses.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Append file in repository is not possible
- Cannot add converters
- ConnectionFileObject.ConnectionWithBucketsRoot.UnsupportedOperation
- ConnectionFileObject.PVFSRoot.UnsupportedOperation
- CsvInput.Log.OnlyLocalFilesAreSupported
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/af554253f7cc3cbb.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/file-open-save-new/core/src/main/java/org/pentaho/di/plugins/fileopensave/providers/vfs/OverwriteAwareFileSelector.java:91
if ( fileInfo.getFile().equals( copyFrom ) ) {
// If the file being worked is the original source then we already answered the overwrite question before the
// copy started. So if this file is a duplicate we already said to overwrite it, or we wouldn't be here.
overwriteStatus.setOverwriteMode( OverwriteStatus.OverwriteMode.OVERWRITE );
} else {
overwriteStatus.promptOverwriteIfNecessary( destinationFileObject.exists(), destinationFile, "folder",
new OverwriteStatus.OverwriteMode[] { OverwriteStatus.OverwriteMode.RENAME },
"Note: rename is not available." );
}
if ( overwriteStatus.isCancel() ) {
// We have to throw an exception or it will keep going through the tree
throw new FileException( "Aborted by user." );
}
if ( overwriteStatus.isSkip() ) {
return false;
}
if ( overwriteStatus.isRename() ) {
//should not happen
throw new IllegalArgumentException(
"Sorry, can not rename on the fly while copying in the same VFS Connection." );
}
return true;
}
private String convertFileInfoToOutputFile( FileSelectInfo fileInfo ) {
String sourceFile = fileInfo.getFile().getName().toString();
if ( !sourceFile.startsWith( copyFrom.getName().toString() ) ) {
throw new IllegalArgumentException( "The incoming file did not start with the source path" );
}
return copyTo.getName().toString() + sourceFile.substring( copyFrom.getName().toString().length() );
}
/**
* Wrapper around {@link KettleVFSService#getFileObject(String, VariableSpace)}
* @param vfsPath
* @param space
* @returnView on GitHub (pinned to f3058517a1)