pentaho/pentaho-kettle · error · KettleException

TextFileInput.Log.Error.ErrorConvertingLineText

TextFileInput.Log.Error.ErrorConvertingLineText

Error message

TextFileInput.Log.Error.ErrorConvertingLineText

What it means

TextFileInputUtils.convertLineToRow() converts a raw text line into a Kettle row using the field definitions (types, masks, delimiters, extra output fields). Any exception in that conversion is wrapped in a KettleException with message TextFileInput.Log.Error.ErrorConvertingLineText. The step-level error handling may divert it, but unhandled it stops the step.

Solutions

  1. Read the chained cause to find which field value failed to convert.
  2. Fix the data or relax the field type (e.g. use String instead of Number for dirty columns).
  3. Correct the conversion masks (date/number formats) in the Fields tab to match the actual data.
  4. Enable the step's error handling (errorIgnored with error/field count targets) to route bad lines to an error stream instead of failing.
  5. Configure the Encoding and trim type to preserve/normalize values before conversion.

Example fix

// before: date mask does not match data
field.setFormat("yyyy-MM-dd"); // data is 31/12/2024
// after: mask matches the data
field.setFormat("dd/MM/yyyy");
Defensive patterns

Strategy: fallback

Validate before calling

// dry-run conversion of each field before running the transformation
for (TextFileInputField f : meta.inputFields) {
  if (f.getFormat() != null && f.getType() == ValueMetaInterface.TYPE_NUMBER)
    new DecimalFormat(f.getFormat()); // throws early on bad mask
}
if (sampleLine.split(Pattern.quote(meta.getDelimiter())).length < meta.inputFields.length)
  log.logBasic("Warning: data rows have fewer columns than defined fields");

Type guard

if (line == null || line.isEmpty() || meta.inputFields == null || meta.inputFields.length == 0) return null; // nothing convertible

Try / catch

try {
  Object[] row = TextFileInputUtils.convertLineToRow(...);
} catch (KettleException e) {
  if (meta.isErrorLineSkipped()) {
    log.logBasic("Skipped bad line: " + e.getCause());
    // route to error stream via step error handling
  } else throw e;
}

Prevention

When it happens

Trigger: Calling convertLineToRow during step processing when a field value cannot be parsed into its configured type (bad number/date against the mask), the row layout/indexing fails, or populating additional output fields (rootUri etc.) throws.

Common situations: Data rows not matching the declared field types (letters in a numeric column); date strings not matching the conversion mask; wrong number of columns vs defined fields with strict handling; trim/encoding settings corrupting values before conversion.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/3522eaf16b7c5afc. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/fileinput/text/TextFileInputUtils.java:643

        }
        // Add modification date
        if ( additionalOutputFields.lastModificationField != null ) {
          r[index] = modificationDateTime;
          index++;
        }
        // Add Uri
        if ( additionalOutputFields.uriField != null ) {
          r[index] = uri;
          index++;
        }
        // Add RootUri
        if ( additionalOutputFields.rootUriField != null ) {
          r[index] = rooturi;
          index++;
        }
      } // End if r != null
    } catch ( Exception e ) {
      throw new KettleException( BaseMessages.getString( PKG, "TextFileInput.Log.Error.ErrorConvertingLineText" ), e );
    }

    if ( r != null && passThruFields != null ) {
      // Simply add all fields from source files step
      for ( int i = 0; i < nrPassThruFields; i++ ) {
        r[i] = passThruFields[i];
      }
    }

    return r;
  }

  public static final String[] convertLineToStrings( LogChannelInterface log, String line, TextFileInputMeta inf,
      String delimiter, String enclosure, String escapeCharacters ) throws KettleException {
    String[] strings = new String[inf.inputFields.length];
    int fieldnr;

    String pol; // piece of line

View on GitHub (pinned to f3058517a1)