pentaho/pentaho-kettle · error · RhinoRuntimeError
The function call deleteFile is not valid.
Error message
The function call deleteFile is not valid.
What it means
deleteFile(path) attempts to delete a file through VFS; when an IOException occurs during the delete operation the implementation throws this Rhino runtime error stating the function call is not valid. The original IOException detail is not included, so the message appears even for ordinary I/O failures like locked or missing files.
Solutions
- Check the file isn't locked/open by another process or step before deleting.
- Verify the user running the transformation has write permission on the file's directory.
- Confirm the path and VFS scheme are correct (e.g. file:/// vs sftp://) and reachable.
- Check the file still exists right before deletion to avoid race conditions.
- Catch the error in the JS script and log/handle it instead of failing the step.
Example fix
// before
deleteFile('/data/out.csv'); // fails if file is locked
// after
try {
deleteFile('/data/out.csv');
} catch (e) {
// log and continue or retry later
} Defensive patterns
Strategy: try-catch
Try / catch
try { deleteFile(path); } catch (e) { if (String(e).indexOf('deleteFile is not valid') >= 0) { logError('Could not delete ' + path + ' - file may be locked or permission denied'); } else { throw e; } } Prevention
- Close files/writers before deleting.
- Run the transformation with sufficient OS permissions.
- Verify VFS path scheme and connectivity before delete.
- Handle delete failures in-script rather than letting the step fail.
When it happens
Trigger: deleteFile('path') throwing IOException during the delete: file locked by another process, no write permission on the directory, VFS provider failing, or the file disappearing between the existence check and delete.
Common situations: Deleting a file still held open by a writer on Windows; running under a user without permissions; network/FTP VFS paths temporarily unreachable; race where another step deleted the file first.
Related errors
- The function call moveFile throw an error : + e.toString()
- Alert dialog cancelled by user.
- Could not convert the String with the given format :
- e.getMessage()
- Error while reading file \"
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/9fa8b7e2e5d0eaac.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:2058
// Object act = actualObject.get("_step_", actualObject);
// ScriptValuesMod act = (ScriptValuesMod)Context.toType(scm_delete, ScriptValuesMod.class);
FileObject fileObject = null;
try {
fileObject = KettleVFS.getInstance( getBowl( actualObject ) ).getFileObject( Context.toString( ArgList[0] ) );
if ( fileObject.exists() ) {
if ( fileObject.getType() == FileType.FILE ) {
if ( !fileObject.delete() ) {
Context.reportRuntimeError( "We can not delete file [" + Context.toString( ArgList[0] ) + "]!" );
}
}
} else {
Context.reportRuntimeError( "file [" + Context.toString( ArgList[0] ) + "] can not be found!" );
}
} catch ( IOException e ) {
throw Context.reportRuntimeError( "The function call deleteFile is not valid." );
} finally {
if ( fileObject != null ) {
try {
fileObject.close();
} catch ( Exception e ) {
// Ignore errors
}
}
}
} else {
throw Context.reportRuntimeError( "The function call deleteFile is not valid." );
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
}
View on GitHub (pinned to f3058517a1)