pentaho/pentaho-kettle · error · KettleException

AbstractFileErrorHandler.Exception.CouldNotCloseFile

AbstractFileErrorHandler.Exception.CouldNotCloseFile

Error message

AbstractFileErrorHandler.Exception.CouldNotCloseFile

What it means

KettleException thrown by AbstractFileErrorHandler.close() when closing one of the cached output writers throws IOException. The error content may not have been fully flushed to the error file, so lineage data can be incomplete.

Solutions

  1. Check disk space on the volume holding the error files (flush failures are usually ENOSPC)
  2. Inspect the chained IOException cause for the exact OS error
  3. Write error files to local reliable storage instead of network mounts for long transformations
  4. Retry the transformation after fixing storage; verify error lineage files were completely written

Example fix

// before: error dir on full disk
/mnt/data/err
// after: free space or redirect
$ df -h /mnt/data; errorTargetDir = "/var/tmp/err"
Defensive patterns

Strategy: try-catch

Validate before calling

// Before run: ensure enough free space for potential error-lineage output
java.io.File dir = new java.io.File(errorDirLocalPath);
long usable = dir.getFreeSpace();
long expectedMax = rowsEstimate * 128; // rough bytes/lineage-line
if (usable < expectedMax) {
  log.warn("Low disk for error lineage: " + usable + " < " + expectedMax);
}

Try / catch

try {
  errorHandler.close();
} catch (KettleException e) {
  log.error("Error lineage file not closed cleanly: " + e.getMessage(), e);
  // verify lineage file completeness before trusting it
  if (e.getCause() instanceof java.io.IOException
      && e.getCause().getMessage().contains("No space left")) {
    alertOps("Disk full on error lineage volume");
  }
}

Prevention

When it happens

Trigger: close() iterates writers and calls outputStreamWriter.close(); the underlying stream throws IOException — disk full during final flush, file handle closed externally, network storage dropped mid-session.

Common situations: Error-lineage files written to a full disk or to a network share that dropped during transformation execution; long-running transformations where file handles were reclaimed.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/step/errorhandling/AbstractFileErrorHandler.java:157

      close( iter.next() );
    }
    writers = new HashMap<Object, Writer>();

  }

  private void close( Writer outputStreamWriter ) throws KettleException {
    if ( outputStreamWriter != null ) {
      try {
        outputStreamWriter.flush();
      } catch ( IOException exception ) {
        baseStep.logError(
          BaseMessages.getString( PKG, "AbstractFileErrorHandler.Log.CouldNotFlushContentToFile" ), exception
            .getLocalizedMessage() );
      }
      try {
        outputStreamWriter.close();
      } catch ( IOException exception ) {
        throw new KettleException( BaseMessages.getString(
          PKG, "AbstractFileErrorHandler.Exception.CouldNotCloseFile" ), exception );
      } finally {
        outputStreamWriter = null;
      }
    }
  }

  public void handleFile( FileObject file ) throws KettleException {
    close();
    this.processingFilename = file.getName().getBaseName();
  }

}

View on GitHub (pinned to f3058517a1)