pentaho/pentaho-kettle · error · KettleException

Error parsing message

Error message

Error parsing message

What it means

A catch-all KettleException thrown by HL7Input.processRow() when any exception occurs while parsing the HL7 message and emitting the resulting fields (message type, trigger event, version, description, value). It wraps the original exception (e), so the root cause (often an HL7 v2 parse error from HapiContext/Parser) is in the cause chain.

Solutions

  1. Inspect the wrapped cause (e.getCause()) to see the exact HL7 parser error
  2. Validate the raw message text (must contain MSH segment and proper \r segment separators)
  3. Ensure the upstream step delivers one complete HL7 message per row
  4. Filter out null/empty rows before the HL7Input step

Example fix

// before
String msg = row[messageFieldIndex]; // may be null
// after
if (row[messageFieldIndex] == null || row[messageFieldIndex].toString().trim().isEmpty()) {
  putRow(outputRowMeta, row); // skip parsing for empty messages
  continue;
}
Defensive patterns

Strategy: try-catch

Validate before calling

String msg = (String) row[idx];
if (msg == null || !msg.startsWith("MSH")) { logBasic("Skipping non-HL7 row"); return; }

Try / catch

try { parseHL7(message); } catch (Exception e) { logError("HL7 parse failed: " + e.getCause(), e); /* route row to error stream */ }

Prevention

When it happens

Trigger: The content of the configured message field is not a valid HL7 v2 message — e.g. wrong MLLP framing, empty/null field value, malformed segments, or the HL7 parser throws while building the Message model.

Common situations: Field contains non-HL7 data (JSON, plain text, truncated message); message split across multiple rows; missing MSH segment; character encoding mismatch garbling segment separators.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


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

Appendix: source

Thrown at plugins/hl7/core/src/main/java/org/pentaho/di/trans/steps/hl7input/HL7Input.java:98

      for ( HL7Value value : values ) {
        Object[] output = RowDataUtil.createResizedCopy( r, data.outputRowMeta.size() );
        int outputIndex = getInputRowMeta().size();

        output[outputIndex++] = value.getParentGroup();
        output[outputIndex++] = value.getGroupName();
        output[outputIndex++] = value.getVersion();
        output[outputIndex++] = value.getStructureName();
        output[outputIndex++] = value.getStructureNumber();
        output[outputIndex++] = value.getFieldName();
        output[outputIndex++] = value.getCoordinate();
        output[outputIndex++] = value.getDataType();
        output[outputIndex++] = value.getDescription();
        output[outputIndex++] = value.getValue();

        putRow( data.outputRowMeta, output );
      }
    } catch ( Exception e ) {
      throw new KettleException( "Error parsing message", e );
    }

    if ( checkFeedback( getLinesWritten() ) ) {
      if ( log.isBasic() ) {
        logBasic( BaseMessages.getString( PKG, "HL7Input.Log.LineNumber" ) + getLinesWritten() );
      }
    }

    return true;
  }
}

View on GitHub (pinned to f3058517a1)