{"record":{"id":"4fac2202d991021a","repo":"pentaho/pentaho-kettle","slug":"textfileinput-log-singlelinefound-4fac22","errorCode":"TextFileInput.Log.SingleLineFound","errorMessage":"TextFileInput.Log.SingleLineFound","messagePattern":"TextFileInput\\.Log\\.SingleLineFound","errorType":"exception","errorClass":"KettleFileException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/textfileinput/TextFileInput.java","lineNumber":110,"sourceCode":"  }\n\n  public static final String getLine( LogChannelInterface log, InputStreamReader reader, EncodingType encodingType,\n      int formatNr, StringBuilder line ) throws KettleFileException {\n    int c = 0;\n    line.setLength( 0 );\n    try {\n      switch ( formatNr ) {\n        case TextFileInputMeta.FILE_FORMAT_DOS:\n          while ( c >= 0 ) {\n            c = reader.read();\n\n            if ( encodingType.isReturn( c ) || encodingType.isLinefeed( c ) ) {\n              c = reader.read(); // skip \\n and \\r\n              if ( !encodingType.isReturn( c ) && !encodingType.isLinefeed( c ) ) {\n                // make sure its really a linefeed or cariage return\n                // raise an error this is not a DOS file\n                // so we have pulled a character from the next line\n                throw new KettleFileException( BaseMessages.getString( PKG, \"TextFileInput.Log.SingleLineFound\" ) );\n              }\n              return line.toString();\n            }\n            if ( c >= 0 ) {\n              line.append( (char) c );\n            }\n          }\n          break;\n        case TextFileInputMeta.FILE_FORMAT_UNIX:\n          while ( c >= 0 ) {\n            c = reader.read();\n\n            if ( encodingType.isLinefeed( c ) || encodingType.isReturn( c ) ) {\n              return line.toString();\n            }\n            if ( c >= 0 ) {\n              line.append( (char) c );\n            }","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/textfileinput/TextFileInput.java#L92-L128","documentation":"TextFileInput.getLine() throws KettleFileException with this message when, after reading a carriage return (\\r), the very next character is NOT a linefeed (\\n). For a DOS/Windows (CRLF) file this would always be a \\n, so finding any other character means the parser has consumed one character from the next line, corrupting line boundaries.","triggerScenarios":"Reading a mixed-line-ending file where a \\r is followed by a real character instead of \\n (e.g. old Mac CR-only line endings embedded in a file being parsed as DOS, or a file with a stray \\r in mid-text) while the encoding type treats \\r\\n as a pair.","commonSituations":"Files edited on different OSes (Unix LF + old Mac CR mixed), files transferred with partial newline conversion, data exports containing stray carriage returns inside quoted fields.","solutions":["Normalize the input file's line endings to LF or CRLF consistently before feeding it to the step (e.g. dos2unix or an editor save-as with a fixed EOL style).","Set the step's line-ending/encoding format explicitly (DOS/Unix) so it matches the actual file content instead of relying on detection.","Pre-process the file to strip stray CR characters not followed by LF (sed -i 's/\\r$//' or equivalent).","If the data legitimately contains bare CRs, enclose fields properly or switch to a parser that tolerates them."],"exampleFix":"// before: file has mixed CR and CRLF endings, step throws\n// after: normalize line endings before the transformation\n//   tr -d '\\r' < input.txt > input.normalized.txt\n// (or set Format to 'Unix' for LF-only files in the Text File Input dialog)","handlingStrategy":"validation","validationCode":"// Pre-check for bare CR not followed by LF before running the step\nboolean hasBareCR = false;\ntry (BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset))) {\n  int prev = -1, c;\n  while ((c = r.read()) != -1) {\n    if (prev == '\\r' && c != '\\n') { hasBareCR = true; break; }\n    prev = c;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  row = textFileInput.getLine();\n} catch (KettleFileException e) {\n  // mixed line endings: normalize file and retry\n  normalizeLineEndings(file);\n  row = textFileInput.getLine();\n}","preventionTips":["Standardize on one line-ending style across all input files","Run dos2unix/line-ending normalization as a pre-processing job entry","Match the step's Format setting (DOS/Unix) to the real file format"],"tags":["file-parsing","line-endings","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"}