pentaho/pentaho-kettle · error · KettleException

FileErrorHandlerContentLineNumber.Exception.CouldNotCreateWriteLine

FileErrorHandlerContentLineNumber.Exception.CouldNotCreateWriteLine

Error message

FileErrorHandlerContentLineNumber.Exception.CouldNotCreateWriteLine

What it means

KettleException thrown by FileErrorHandlerContentLineNumber.handleLineError() when writing the line number of a rejected row to the content-error file fails. The line number itself is fine — the failure is in obtaining or writing to the underlying writer (delegated to AbstractFileErrorHandler.getWriter).

Solutions

  1. Fix the error-handling file location: ensure it exists, is writable, and the URI is valid (see the chained cause)
  2. Check the chained KettleException cause — it's usually a file-open failure from AbstractFileErrorHandler.getWriter
  3. Free disk space if writes fail mid-run; monitor for excessive bad rows flooding the error file
  4. Pre-test error handling settings with a small sample file in Spoon

Example fix

// before: error dir missing
<p>Bad rows go to /logs/lineage (nonexistent)</p>
// after
mkdir -p /logs/lineage && chmod u+w /logs/lineage
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight the lineage target before processing rows
FileObject lineage = KettleVFS.getInstance(DefaultBowl.getInstance())
  .getFileObject(errorFileUri);
if (!lineage.getParent().exists() || !lineage.getParent().isWriteable()) {
  throw new KettleException("Lineage file location not writable: " + errorFileUri);
}

Try / catch

try {
  errorHandler.handleLineError(lineNr, part);
} catch (KettleException e) {
  log.error("Could not record bad line " + lineNr + ": " + e.getMessage(), e);
  // stop the run rather than silently losing lineage records
  throw e;
}

Prevention

When it happens

Trigger: handleLineError(lineNr, filePart) called for each bad row; getWriter(filePart).write(...) throws because the error file could not be created/opened (see file-open failures) or the write itself failed (disk full, stream closed).

Common situations: Text file input steps with error handling enabled where the error directory is missing/read-only; first bad row triggers lazy writer creation which then fails; disk fills mid-run after many bad lines.

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/31acb28d89b24fd2. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/step/errorhandling/FileErrorHandlerContentLineNumber.java:38

import org.pentaho.di.core.Const;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.trans.step.BaseStep;

public class FileErrorHandlerContentLineNumber extends AbstractFileErrorHandler {
  private static Class<?> PKG = FileErrorHandlerContentLineNumber.class; // for i18n purposes, needed by Translator2!!

  public FileErrorHandlerContentLineNumber( Date date, String destinationDirectory, String fileExtension,
    String encoding, BaseStep baseStep ) {
    super( date, destinationDirectory, fileExtension, encoding, baseStep );
  }

  public void handleLineError( long lineNr, String filePart ) throws KettleException {
    try {
      getWriter( filePart ).write( String.valueOf( lineNr ) );
      getWriter( filePart ).write( Const.CR );
    } catch ( Exception e ) {
      throw new KettleException( BaseMessages.getString(
        PKG, "FileErrorHandlerContentLineNumber.Exception.CouldNotCreateWriteLine" )
        + lineNr, e );

    }
  }

  public void handleNonExistantFile( FileObject file ) {
  }

  public void handleNonAccessibleFile( FileObject file ) {
  }

}

View on GitHub (pinned to f3058517a1)