pentaho/pentaho-kettle · warning · RuntimeException

Unexpected error encoding job result as XML

Error message

Unexpected error encoding job result as XML

What it means

Result.getXML() serializes job/transformation execution results (rows, files, metrics) to XML using XMLHandler, which can throw IOException from Writer/StringWriter usage. The library wraps any such IOException in a RuntimeException because XML building in memory is not expected to fail.

Solutions

  1. Inspect the wrapped cause (getCause()) to find the actual IOException source
  2. Review custom XMLHandler implementations or subclasses for real I/O in serialization
  3. Retry serialization after resolving the environmental I/O problem
  4. If results are huge, reduce streamed result rows before serializing

Example fix

// before
String xml = result.getXML();
// after
String xml;
try {
  xml = result.getXML();
} catch (RuntimeException e) {
  log.error("XML serialization of Result failed", e.getCause());
  xml = "";
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  String xml = result.getXML();
} catch (RuntimeException e) {
  // unwrap IOException via e.getCause() and log; degrade gracefully
}

Prevention

When it happens

Trigger: Calling getXML() when the underlying serialization raises IOException — practically rare, but possible via an XMLHandler path performing unexpected I/O or an environment failure while building the string buffer.

Common situations: Custom Result subclasses or patched XMLHandler doing real I/O during serialization, JVM-level resource issues, or passing unusually large result sets triggering underlying stream problems.

Understand the failure class

Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.

Related errors


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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/Result.java:616

      xml.append( XMLHandler.openTag( XML_ROWS_TAG ) );
      boolean firstRow = true;
      RowMetaInterface rowMeta = null;
      for ( RowMetaAndData row : rows ) {
        if ( firstRow ) {
          firstRow = false;
          rowMeta = row.getRowMeta();
          xml.append( rowMeta.getMetaXML() );
        }
        xml.append( rowMeta.getDataXML( row.getData() ) );
      }
      xml.append( XMLHandler.closeTag( XML_ROWS_TAG ) );

      xml.append( XMLHandler.closeTag( XML_TAG ) );

      return xml.toString();
    } catch ( IOException e ) {
      throw new RuntimeException( "Unexpected error encoding job result as XML", e );
    }
  }

  private StringBuilder setBasicXmlAttrs( StringBuilder xml ) {
    // First the metrics...
    //
    xml.append( XMLHandler.addTagValue( "lines_input", nrLinesInput ) );
    xml.append( XMLHandler.addTagValue( "lines_output", nrLinesOutput ) );
    xml.append( XMLHandler.addTagValue( "lines_read", nrLinesRead ) );
    xml.append( XMLHandler.addTagValue( "lines_written", nrLinesWritten ) );
    xml.append( XMLHandler.addTagValue( "lines_updated", nrLinesUpdated ) );
    xml.append( XMLHandler.addTagValue( "lines_rejected", nrLinesRejected ) );
    xml.append( XMLHandler.addTagValue( "lines_deleted", nrLinesDeleted ) );
    xml.append( XMLHandler.addTagValue( "nr_errors", nrErrors ) );
    xml.append( XMLHandler.addTagValue( "nr_files_retrieved", nrFilesRetrieved ) );
    xml.append( XMLHandler.addTagValue( "entry_nr", entryNr ) );

    // The high level results...

View on GitHub (pinned to f3058517a1)