pentaho/pentaho-kettle · error · RuntimeException

: there was a value XML encoding error

Error message

 : there was a value XML encoding error

What it means

In ValueMetaBase.getXML, after the type-specific and storage-type-specific handling, any remaining Exception during value-to-XML encoding (e.g. date/number formatting failures) is caught and rethrown as a RuntimeException with this message. It means the value could not be encoded to its XML string form for reasons other than a hard type mismatch.

Solutions

  1. Read the cause (RuntimeException.getCause()) to find the actual encoding failure and fix it (format mask, charset, toString implementation).
  2. Validate the value meta's conversion format masks (setConversionMask) — invalid patterns break encoding.
  3. Convert custom objects to supported Java types before putting them into the row.
  4. Test getXML on a sample row in isolation to reproduce and pinpoint the failing value.

Example fix

// before: bad mask causes encoding exception
vm.setConversionMask("dd/MM/yyyy HH:mm:ss SSS 'x'"); // malformed pattern
// after
vm.setConversionMask("dd/MM/yyyy HH:mm:ss");
Defensive patterns

Strategy: try-catch

Validate before calling

try {
  new SimpleDateFormat(vm.getConversionMask());
} catch (IllegalArgumentException iae) {
  throw new IllegalStateException("Invalid conversion mask: " + vm.getConversionMask());
}

Try / catch

try {
  String xml = valueMeta.getXML(data);
} catch (RuntimeException e) {
  if (e.getMessage() != null && e.getMessage().contains("value XML encoding error")) {
    logError("XML encoding failed for " + valueMeta.getName() + ": " + e.getCause(), e.getCause());
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling getXML(object) where encoding fails inside the type branch — e.g. XMLHandler.string2string/escaping problems, a formatting exception from a broken conversion mask, or an unexpected exception thrown while converting the object's string representation.

Common situations: Malformed conversion format strings set on the value meta; custom data objects whose toString() throws; encoding/charset issues producing invalid intermediate strings; plugin values not conforming to the expected contract.

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/0fea89cf55dd6a48. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java:3401

            //
            string = XMLHandler.addTagValue( "binary-string", (byte[]) object );
            xml.append( XMLHandler.openTag( XML_DATA_TAG ) ).append( string ).append( XMLHandler.closeTag( XML_DATA_TAG ) );
            return xml.toString();

          case STORAGE_TYPE_INDEXED:
            // Just an index
            string = XMLHandler.addTagValue( "index-value", (Integer) object );
            break;

          default:
            throw new IOException( toString() + " : Unknown storage type " + getStorageType() );
        }
      } catch ( ClassCastException e ) {
        throw new RuntimeException( toString() + " : There was a data type error: the data type of "
            + object.getClass().getName() + " object [" + object + "] does not correspond to value meta ["
            + toStringMeta() + "]", e );
      } catch ( Exception e ) {
        throw new RuntimeException( toString() + " : there was a value XML encoding error", e );
      }
    } else {
      // If the object is null: give an empty string
      //
      string = "";
    }
    xml.append( XMLHandler.addTagValue( XML_DATA_TAG, string ) );

    return xml.toString();
  }

  /**
   * Convert a data XML node to an Object that corresponds to the metadata. This is basically String to Object
   * conversion that is being done.
   *
   * @param node
   *          the node to retrieve the data value from
   * @return the converted data value

View on GitHub (pinned to f3058517a1)