{"record":{"id":"9c478a7c89282f80","repo":"pentaho/pentaho-kettle","slug":"processfiles-error-cannotdeletefile","errorCode":null,"errorMessage":"ProcessFiles.Error.CanNotDeleteFile","messagePattern":"ProcessFiles\\.Error\\.CanNotDeleteFile","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/processfiles/ProcessFiles.java","lineNumber":193,"sourceCode":"          if ( ( ( meta.isOverwriteTargetFile() && data.targetFile.exists() ) || !data.targetFile.exists() )\n            && !meta.simulate ) {\n            data.sourceFile.moveTo( KettleVFS.getInstance( getTransMeta().getBowl() )\n                                    .getFileObject( targetFilename, getTransMeta() ) );\n            if ( log.isDetailed() ) {\n              logDetailed( BaseMessages.getString(\n                PKG, \"ProcessFiles.Log.SourceFileMoved\", sourceFilename, targetFilename ) );\n            }\n          } else {\n            if ( log.isDetailed() ) {\n              logDetailed( BaseMessages.getString(\n                PKG, \"ProcessFiles.Log.TargetNotOverwritten\", sourceFilename, targetFilename ) );\n            }\n          }\n          break;\n        case ProcessFilesMeta.OPERATION_TYPE_DELETE:\n          if ( !meta.simulate ) {\n            if ( !data.sourceFile.delete() ) {\n              throw new KettleException( BaseMessages.getString(\n                PKG, \"ProcessFiles.Error.CanNotDeleteFile\", data.sourceFile.toString() ) );\n            }\n          }\n          if ( log.isDetailed() ) {\n            logDetailed( BaseMessages.getString( PKG, \"ProcessFiles.Log.SourceFileDeleted\", sourceFilename ) );\n          }\n          break;\n        default:\n\n          break;\n      }\n\n      // add filename to result filenames?\n      if ( meta.isaddTargetFileNametoResult()\n        && meta.getOperationType() != ProcessFilesMeta.OPERATION_TYPE_DELETE\n        && data.sourceFile.getType() == FileType.FILE ) {\n        // Add this to the result file names...\n        ResultFile resultFile =","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/processfiles/ProcessFiles.java#L175-L211","documentation":"Thrown during OPERATION_TYPE_DELETE when data.sourceFile.delete() returns false, i.e. VFS could not delete the source file. Unlike exceptions, a false return means the file system refused or failed the delete without throwing (e.g. permission or lock).","triggerScenarios":"Operation type Delete, simulate is false, and FileObject.delete() returns false for the resolved source file.","commonSituations":"File is read-only or owned by another user/process (insufficient permissions); file locked/open by another application (Windows); file on a read-only mount or protected system directory; VFS caching showing stale file state.","solutions":["Check and grant delete (write) permissions on the file and its containing directory for the user running PDI.","Close any application holding the file open (check with lsof/handle) or stop the locking process.","Ensure the mount/filesystem is writable (not read-only) and the service account has rights.","Run the transformation as a user with sufficient OS-level privileges; on shared/NFS storage verify export permissions.","Add step error handling so failed deletes are logged and retried later."],"exampleFix":"// before\nchmod 444 /data/in/file.txt\n// after\nchmod 644 /data/in/file.txt && chown pdiuser /data/in/file.txt","handlingStrategy":"try-catch","validationCode":"// Guard: file exists and is writable before delete\njava.io.File f = new java.io.File(sourceFilename);\nboolean deletable = f.exists() && f.canWrite() && f.getParentFile().canWrite();","typeGuard":"boolean isDeletable(String path) {\n  java.io.File f = (path == null) ? null : new java.io.File(path);\n  return f != null && f.isFile() && f.canWrite() && f.getParentFile() != null && f.getParentFile().canWrite();\n}","tryCatchPattern":"try {\n  processRow();\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"CanNotDeleteFile\")) {\n    logError(\"Delete failed (locked or permission denied): \" + extractPath(e));\n    // queue for retry\n  } else throw e;\n}","preventionTips":["Run PDI as a user with write access to the source directories","Ensure no other process holds the files open during the run","Check mount read-only status and NFS/SMB permissions","Use 'simulate' mode first to verify which files would be deleted"],"tags":["pdi","kettle","file-delete","permissions"],"backgroundTag":"file-delete-failed","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"}