pentaho/pentaho-kettle · error · RuntimeException
The function call deleteFile is not valid.
Error message
The function call deleteFile is not valid.
What it means
Inside deleteFile(), any IOException raised while resolving or inspecting the file object is swallowed and replaced with the generic message 'The function call deleteFile is not valid.' This indicates the VFS/IO layer failed (bad URI, unsupported scheme, connection error) rather than the file simply not existing.
Solutions
- Wrap the raw RuntimeException in a try-catch in your script and log the underlying cause — this throw discards the original IOException, so reproduce the path with KettleVFS directly for a real message.
- Validate the path is a well-formed VFS URI (correct scheme, forward slashes, no illegal characters) before calling.
- Test the same path with a 'Text File Input' step or KettleVFS in a small script to see the true IOException.
- Prefer java.io.File/java.nio.file.Files for plain local paths instead of deleteFile() to get clearer errors.
Example fix
// before
deleteFile('C:\\data\\out.txt'); // backslashes break VFS URI
// after
deleteFile('file:///C:/data/out.txt'); Defensive patterns
Strategy: type-guard
Validate before calling
// reject paths VFS cannot parse before calling
if (!/^[a-z]+:\/\//.test(path) && path.indexOf('\\') >= 0) { throw new Error('normalize path first'); } Type guard
function isVfsUri(p) { return typeof p === 'string' && (/^[a-z]+:\/\//.test(p) || p.startsWith('/')); } Try / catch
try { deleteFile(path); } catch (e) { // message hides the real IOException; retry path via java.io.File to diagnose
var f = new java.io.File(path); if (!f.delete()) throw new Error('delete failed: ' + path); } Prevention
- Use forward slashes and proper schemes in paths
- Validate URIs before calling VFS-backed helpers
- For local files prefer java.nio APIs with clearer errors
When it happens
Trigger: Calling deleteFile() with a malformed VFS URI or unsupported scheme (the KettleVFS.getFileObject call throws IOException), or an IO error while calling exists()/type checks.
Common situations: Passing a Windows path with backslashes or drive letters that VFS cannot parse; using schemes like sftp:/ with missing/invalid connection config; typos in the URI (e.g. 'htp://'); special characters in the filename that break URI parsing.
Understand the failure class
Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.
Related errors
- The function call copyFile throw an error :
- AbstractFileErrorHandler.Exception.CouldNotCreateFileErrorHandlerForFile
- AvroInputDialog.Error.KettleFileException
- ERROR_0001_TARGET_EXISTS
- Error opening file [" + data.filename + "]!
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/d75955437f8a6f05.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:1970
// Object act = actualObject.get("_step_", actualObject);
// ScriptValuesMod act = (ScriptValuesMod)Context.toType(scm_delete, ScriptValuesMod.class);
FileObject fileObject = null;
try {
fileObject = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );
if ( fileObject.exists() ) {
if ( fileObject.getType() == FileType.FILE ) {
if ( !fileObject.delete() ) {
throw new RuntimeException( "We can not delete file [" + (String) ArgList[0] + "]!" );
}
}
} else {
throw new RuntimeException( "file [" + ArgList[0] + "] can not be found!" );
}
} catch ( IOException e ) {
throw new RuntimeException( "The function call deleteFile is not valid." );
} finally {
if ( fileObject != null ) {
try {
fileObject.close();
} catch ( Exception e ) {
// Ignore errors
}
}
}
} else {
throw new RuntimeException( "The function call deleteFile is not valid." );
}
} catch ( Exception e ) {
throw new RuntimeException( e.toString() );
}
}
View on GitHub (pinned to f3058517a1)