{"record":{"id":"8f8bf135eeaa7975","repo":"pentaho/pentaho-kettle","slug":"unable-to-delete-file-with-name-filename","errorCode":null,"errorMessage":"Unable to delete file with name [ + filename + ]","messagePattern":"Unable to delete file with name \\[ \\+ filename \\+ \\]","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/filerep/KettleFileRepository.java","lineNumber":459,"sourceCode":"  }\n\n  public void deleteRootObject( String name, String extension ) throws KettleException {\n    try {\n      String filename = calcDirectoryName( null ) + name + extension;\n      FileObject fileObject = KettleVFS.getInstance( DefaultBowl.getInstance() ).getFileObject( filename );\n      fileObject.delete();\n    } catch ( Exception e ) {\n      throw new KettleException( \"Unable to delete database with name [\"\n        + name + \"] and extension [\" + extension + \"]\", e );\n    }\n  }\n\n  public void deleteFile( String filename ) throws KettleException {\n    try {\n      FileObject fileObject = KettleVFS.getInstance( DefaultBowl.getInstance() ).getFileObject( filename );\n      fileObject.delete();\n    } catch ( Exception e ) {\n      throw new KettleException( \"Unable to delete file with name [\" + filename + \"]\", e );\n    }\n  }\n\n  @Override\n  public ObjectId getClusterID( String name ) throws KettleException {\n    // The ID is the filename relative to the base directory, including the file extension\n    //\n    return new StringObjectId( calcObjectId( (RepositoryDirectory) null ) + name + EXT_SLAVE_SERVER );\n  }\n\n  @Override\n  public ObjectId[] getClusterIDs( boolean includeDeleted ) throws KettleException {\n    return getRootObjectIDs( EXT_CLUSTER_SCHEMA );\n  }\n\n  @Override\n  public String[] getClusterNames( boolean includeDeleted ) throws KettleException {\n    return convertRootIDsToNames( getClusterIDs( false ) );","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/filerep/KettleFileRepository.java#L441-L477","documentation":"deleteFile() removes an arbitrary file from the file repository by absolute filename via VFS; any failure is wrapped in this KettleException naming the file. It is the low-level delete used by delObject and deletions of cluster schemas, partition schemas, and slaves.","triggerScenarios":"Any delete path that resolves to deleteFile(filename) where the FileObject cannot be resolved or deleted: nonexistent file, locked file, permission denied, invalid filename, or VFS provider errors.","commonSituations":"Deleting shared objects from a file repository whose files were moved externally; Windows file locks; wrong repository base directory configured so computed filenames don't exist; read-only mounts.","solutions":["Check the chained cause to distinguish missing-file vs permission/lock failures.","Verify the repository base directory configuration — wrong base yields wrong computed filenames.","Release file locks (close other Spoon instances / processes) and retry.","Ensure delete permission on the repository directory for the running user."],"exampleFix":"// before\ndeleteFile(filename); // throws if path wrong\n\n// after: validate computed path against repo base first\nif (!filename.startsWith(calcDirectoryName(null))) {\n  throw new IllegalArgumentException(\"Refusing delete outside repo: \" + filename);\n}\ndeleteFile(filename);","handlingStrategy":"try-catch","validationCode":"boolean insideRepo = filename.startsWith(calcDirectoryName(null));\nboolean exists = new File(filename).exists();","typeGuard":null,"tryCatchPattern":"try {\n  repo.deleteFile(filename);\n} catch (KettleException e) {\n  if (e.getMessage().startsWith(\"Unable to delete file\")) {\n    log.error(\"Delete failed for \" + filename + \": \" + e.getCause());\n  } else { throw e; }\n}","preventionTips":["Verify the repository base directory is configured correctly","Release Windows file locks (other Spoon instances) before deletes","Guard against deleting paths outside the repo base","Inspect the chained cause for missing-file vs permission issues"],"tags":["kettle","file-repository","file-delete","io"],"backgroundTag":"file-not-found","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"}