{"record":{"id":"c5a0c67cf528550f","repo":"pentaho/pentaho-kettle","slug":"textfileinput-log-error-exceptionreadingline","errorCode":"TextFileInput.Log.Error.ExceptionReadingLine","errorMessage":"TextFileInput.Log.Error.ExceptionReadingLine","messagePattern":"TextFileInput\\.Log\\.Error\\.ExceptionReadingLine","errorType":"exception","errorClass":"KettleFileException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/fileinput/text/TextFileInputUtils.java","lineNumber":418,"sourceCode":"                  reader.reset();\n                }\n                return line.toString();\n              }\n            } else {\n              if ( c >= 0 ) {\n                line.append( (char) c );\n              }\n            }\n          }\n          break;\n        default:\n          break;\n      }\n    } catch ( KettleFileException e ) {\n      throw e;\n    } catch ( Exception e ) {\n      if ( line.length() == 0 ) {\n        throw new KettleFileException( BaseMessages.getString( PKG, \"TextFileInput.Log.Error.ExceptionReadingLine\", e\n            .toString() ), e );\n      }\n      return line.toString();\n    }\n    if ( line.length() > 0 ) {\n      return line.toString();\n    }\n\n    return null;\n  }\n\n  public static final Object[] convertLineToRow( LogChannelInterface log, TextFileLine textFileLine,\n                                                 TextFileInputMeta info, Object[] passThruFields, int nrPassThruFields, RowMetaInterface outputRowMeta,\n                                                 RowMetaInterface convertRowMeta, String fname, long rowNr, String delimiter, String enclosure,\n                                                 String escapeCharacter, FileErrorHandler errorHandler,\n                                                 BaseFileInputAdditionalField additionalOutputFields, String shortFilename, String path,\n                                                 boolean hidden, Date modificationDateTime, String uri, String rooturi, String extension, Long size )\n    throws KettleException {","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/fileinput/text/TextFileInputUtils.java#L400-L436","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: reading a remote file stream directly\nInputStream in = KettleVFS.getInputStream(filename);\n// after: copy to local temp file first\nFile tmp = File.createTempFile(\"kettle\", \".txt\");\nFiles.copy(KettleVFS.getInputStream(filename), tmp.toPath(), StandardCopyOption.REPLACE_EXISTING);\nInputStream in = new BufferedInputStream(new FileInputStream(tmp));","handlingStrategy":"try-catch","validationCode":"FileObject f = KettleVFS.getFileObject(filename, transMeta);\nif (!f.exists() || f.getContent().getSize() == 0) {\n  throw new KettleFileException(\"File missing or empty: \" + f.getName().getURI());\n}","typeGuard":"if (reader == null) return false; // no usable stream for getLine","tryCatchPattern":"try {\n  String line = TextFileInputUtils.getLine(log, reader, encodingType, enc, ...);\n} catch (KettleFileException e) {\n  if (String.valueOf(e.getMessage()).contains(\"ExceptionReadingLine\")) {\n    log.logError(\"Read failed at line start: \" + e.getCause(), e);\n    // retry or switch to a local copy of the file\n  } else throw e;\n}","preventionTips":["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."],"tags":["kettle","etl","io-exception","line-reading"],"backgroundTag":"file-read-failed","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"}