pentaho/pentaho-kettle · error · RuntimeException

file [

Error message

file [

What it means

The deleteFile() script helper throws 'file [name] can not be found!' when KettleVFS reports that the requested path does not exist. This is an existence check before deletion — the path resolved successfully but no file is present.

Solutions

  1. Check the file exists before calling deleteFile (use fileExists()) and skip deletion gracefully if absent.
  2. Use an absolute path instead of a relative one to remove working-directory dependence.
  3. Fix the filename casing/separators for the target OS filesystem.
  4. Verify an earlier step did not already delete or rename the file.

Example fix

// before
deleteFile('data/out.csv'); // may not exist
// after
if (fileExists('data/out.csv')) { deleteFile('data/out.csv'); }
Defensive patterns

Strategy: validation

Validate before calling

if (fileExists(path)) { deleteFile(path); }

Type guard

function isNonEmptyString(s) { return typeof s === 'string' && s.trim().length > 0; }

Try / catch

try { deleteFile(path); } catch (e) { if (String(e).indexOf('can not be found') >= 0) { /* already gone: ignore */ } else { throw e; } }

Prevention

When it happens

Trigger: Calling deleteFile('somePath') where fileObject.exists() returns false: the path is wrong, the file was already deleted, or relative paths resolve to a different working directory than expected.

Common situations: Typos or wrong separators in the path; deleting the same file twice in one script/loop; running the transformation from a different working directory so a relative path no longer points at the file; case-sensitive filesystems (Linux) vs the filename's casing.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/62d5ecf23f73e020. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:1967

    try {
      if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {
        // 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)