{"record":{"id":"7b31fdfa7f7cc801","repo":"pentaho/pentaho-kettle","slug":"textfileinput-log-error-exceptionreadingline-7b31fd","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/textfileinput/TextFileInput.java","lineNumber":153,"sourceCode":"            c = reader.read();\n\n            if ( encodingType.isLinefeed( c ) ) {\n              return line.toString();\n            } else if ( !encodingType.isReturn( c ) ) {\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  @Deprecated\n  public static final String[] guessStringsFromLine( LogChannelInterface log, String line, TextFileInputMeta inf,\n      String delimiter ) throws KettleException {\n    return guessStringsFromLine( new Variables(), log, line, inf, delimiter, StringUtil.substituteHex( inf\n        .getEnclosure() ), StringUtil.substituteHex( inf.getEscapeCharacter() ) );\n  }\n","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/textfileinput/TextFileInput.java#L135-L171","documentation":"getLine() wraps any unexpected Exception thrown while reading characters from the file into a KettleFileException with this message — but only when no partial line has been accumulated (line.length()==0). If some characters were already read, they are returned as the line instead. The original exception is attached as the cause.","triggerScenarios":"Any I/O or decoding failure during reader.read() in getLine() (e.g. character-decoding errors, stream closed, underlying file system error) at the very start of a line.","commonSituations":"Encoding mismatches (file bytes invalid for the chosen character set), files removed or truncated mid-read on network shares, VFS connection drops while reading remote files.","solutions":["Check the attached cause (e.toString() is embedded in the message) to identify the real I/O or charset problem.","Verify the step's Encoding setting matches the file's actual encoding (UTF-8 vs ISO-8859-1 etc.).","Re-check the file exists and is readable/stable on disk or the network location during the transformation run.","If remote (SFTP/VFS), test connectivity and copy the file locally before processing."],"exampleFix":"// before: Encoding=UTF-8 but file is ISO-8859-1 with invalid byte sequences\n// after: set the Text File Input step Encoding to ISO-8859-1\n//   (Content tab -> Encoding -> ISO-8859-1) to match the source file","handlingStrategy":"try-catch","validationCode":"// Verify the file decodes cleanly with the configured charset before processing\nCharset cs = Charset.forName(encoding);\nnew String(Files.readAllBytes(path), cs); // throws MalformedInputException-related errors early\nCharsetDecoder strict = cs.newDecoder();\nstrict.decode(ByteBuffer.wrap(Files.readAllBytes(path)));","typeGuard":null,"tryCatchPattern":"try {\n  line = getLine();\n} catch (KettleFileException e) {\n  Throwable cause = e.getCause();\n  logError(\"Line read failed: \" + cause, e);\n  if (isRecoverableIO(cause)) { retryWithBackoff(); } else { failStep(); }\n}","preventionTips":["Always set Encoding explicitly to match the source file","Validate file decodability before the transformation runs","Keep files local/stable during processing; avoid reading from flaky network shares"],"tags":["io","file-parsing","text-file-input"],"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"}