pentaho/pentaho-kettle · error · KettleFileException
TextFileInput.Log.Error.ExceptionReadingLine
TextFileInput.Log.Error.ExceptionReadingLine
Error message
TextFileInput.Log.Error.ExceptionReadingLine
What it means
In TextFileInputUtils.getLine(), unexpected exceptions while reading a line are wrapped in KettleFileException 'TextFileInput.Log.Error.ExceptionReadingLine' with e.toString(), but only when nothing was read yet (line.length() == 0). If some characters were already read, the partial line is returned instead. KettleFileException from the inner logic is rethrown unchanged.
Solutions
- Inspect the cause string in the message to identify the underlying IO/decode error.
- Retry the file read; for remote files use a local copy first to avoid flaky streams.
- Confirm the configured encoding matches the file's actual encoding.
- Verify the file is complete and not being written concurrently (check size/locks).
- If partial lines are acceptable, rely on the built-in behavior of returning the partial line; otherwise fix the stream source.
Example fix
// before: reading a remote file stream directly
InputStream in = KettleVFS.getInputStream(filename);
// after: copy to local temp file first
File tmp = File.createTempFile("kettle", ".txt");
Files.copy(KettleVFS.getInputStream(filename), tmp.toPath(), StandardCopyOption.REPLACE_EXISTING);
InputStream in = new BufferedInputStream(new FileInputStream(tmp)); Defensive patterns
Strategy: try-catch
Validate before calling
FileObject f = KettleVFS.getFileObject(filename, transMeta);
if (!f.exists() || f.getContent().getSize() == 0) {
throw new KettleFileException("File missing or empty: " + f.getName().getURI());
} Type guard
if (reader == null) return false; // no usable stream for getLine
Try / catch
try {
String line = TextFileInputUtils.getLine(log, reader, encodingType, enc, ...);
} catch (KettleFileException e) {
if (String.valueOf(e.getMessage()).contains("ExceptionReadingLine")) {
log.logError("Read failed at line start: " + e.getCause(), e);
// retry or switch to a local copy of the file
} else throw e;
} Prevention
- Copy remote files locally before parsing to avoid mid-stream disconnects.
- Ensure the file is fully written/complete before reading (no concurrent writers).
- Match the configured encoding to the file's real encoding.
- Wrap readers in BufferedInputStream for stability on large files.
When it happens
Trigger: getLine() or sline() hitting an IOException/decode error from the underlying reader at the start of a line: stream closed mid-read, network VFS stream reset, character decode failure on the first bytes of a line.
Common situations: Remote file (SFTP/HTTP/S3) connection dropped mid-read; file truncated or being written while read; encoding mismatch producing decode exceptions at line start; reader passed to the step already consumed/closed.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- TextFileInputDialog.Exception.ErrorGettingFirstLines
- ChangeFileEncoding.Error.CreatingFile
- ChangeFileEncoding.Error.ParentFolderNotExist
- ChangeFileEncoding.Error.SourceFileNotAFile
- ChangeFileEncoding.Error.SourceFileNotExists
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/c5a0c67cf528550f.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/fileinput/text/TextFileInputUtils.java:418
reader.reset();
}
return line.toString();
}
} else {
if ( c >= 0 ) {
line.append( (char) c );
}
}
}
break;
default:
break;
}
} catch ( KettleFileException e ) {
throw e;
} catch ( Exception e ) {
if ( line.length() == 0 ) {
throw new KettleFileException( BaseMessages.getString( PKG, "TextFileInput.Log.Error.ExceptionReadingLine", e
.toString() ), e );
}
return line.toString();
}
if ( line.length() > 0 ) {
return line.toString();
}
return null;
}
public static final Object[] convertLineToRow( LogChannelInterface log, TextFileLine textFileLine,
TextFileInputMeta info, Object[] passThruFields, int nrPassThruFields, RowMetaInterface outputRowMeta,
RowMetaInterface convertRowMeta, String fname, long rowNr, String delimiter, String enclosure,
String escapeCharacter, FileErrorHandler errorHandler,
BaseFileInputAdditionalField additionalOutputFields, String shortFilename, String path,
boolean hidden, Date modificationDateTime, String uri, String rooturi, String extension, Long size )
throws KettleException {View on GitHub (pinned to f3058517a1)