pentaho/pentaho-kettle · error · KettleXMLException

Unexpected error parsing Drag & Drop XML fragment: " + xml

Error message

Unexpected error parsing Drag & Drop XML fragment: " + xml

What it means

The DragAndDropContainer constructor parses a drag-and-drop XML fragment (ID, DragType, Base64-encoded Data); any exception during parsing/decoding is rethrown as a KettleXMLException whose message includes the raw XML string. It means the clipboard/tree payload handed to the container was not a valid Drag&Drop XML fragment.

Solutions

  1. Inspect the raw XML in the message — confirm it contains <DragAndDrop> with ID, DragType and Data tags.
  2. Regenerate the drag payload by re-dragging from the source tree instead of reusing stored/stale XML.
  3. If triggered programmatically, build the XML via DragAndDropContainer.getXML() rather than string concatenation.
  4. Upgrade both PDI sides to matching versions if this occurs during cross-version drag-and-drop.

Example fix

// before: hand-built fragment missing Data
String xml = "<DragAndDrop><ID>1</ID><DragType>TRANS</DragType></DragAndDrop>";
// after: produce the payload via the container itself
String xml = new DragAndDropTree(...).getXML(); // includes Base64-encoded Data
Defensive patterns

Strategy: try-catch

Validate before calling

// validate the fragment shape before constructing the container
boolean valid = xml != null && xml.contains("<ID>") && xml.contains("<DragType>") && xml.contains("<Data>");
if (!valid) throw new IllegalArgumentException("Not a DragAndDrop XML fragment");

Try / catch

try { DragAndDropContainer c = new DragAndDropContainer(xml); }
catch (KettleXMLException e) {
  log.error("Bad drag&drop payload: " + e.getMessage());
  // discard the stale clipboard fragment and ask the user to re-drag
}

Prevention

When it happens

Trigger: Constructing DragAndDropContainer from an XML string: XMLHandler.getTagValue returns null or malformed values, getType fails on an unknown DragType, or Base64 decoding of the 'Data' tag throws — all caught and rethrown with the offending xml appended to the message.

Common situations: Dragging between PDI versions where the payload format changed, corrupted clipboard content, plugins producing non-standard DnD fragments, programmatic construction with a hand-built XML string missing required tags.

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

Appendix: source

Thrown at ui/src/main/java/org/pentaho/di/core/dnd/DragAndDropContainer.java:168

  }

  /**
   * Construct a Drag and drop container from an XML String
   *
   * @param xml
   *          The XML string to convert from
   */
  public DragAndDropContainer( String xml ) throws KettleXMLException {
    try {
      Document doc = XMLHandler.loadXMLString( xml );
      Node dnd = XMLHandler.getSubNode( doc, XML_TAG );

      id = XMLHandler.getTagValue( dnd, "ID" );
      type = getType( XMLHandler.getTagValue( dnd, "DragType" ) );
      data =
        new String( Base64.decodeBase64( XMLHandler.getTagValue( dnd, "Data" ).getBytes() ), Const.XML_ENCODING );
    } catch ( Exception e ) {
      throw new KettleXMLException( "Unexpected error parsing Drag & Drop XML fragment: " + xml, e );
    }
  }

}

View on GitHub (pinned to f3058517a1)