{"record":{"id":"d81ad086bfd2f484","repo":"pentaho/pentaho-kettle","slug":"unexpected-error-parsing-drag-drop-xml-fragment-xml","errorCode":null,"errorMessage":"Unexpected error parsing Drag & Drop XML fragment: \" + xml","messagePattern":"Unexpected error parsing Drag & Drop XML fragment: \" \\+ xml","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"ui/src/main/java/org/pentaho/di/core/dnd/DragAndDropContainer.java","lineNumber":168,"sourceCode":"  }\n\n  /**\n   * Construct a Drag and drop container from an XML String\n   *\n   * @param xml\n   *          The XML string to convert from\n   */\n  public DragAndDropContainer( String xml ) throws KettleXMLException {\n    try {\n      Document doc = XMLHandler.loadXMLString( xml );\n      Node dnd = XMLHandler.getSubNode( doc, XML_TAG );\n\n      id = XMLHandler.getTagValue( dnd, \"ID\" );\n      type = getType( XMLHandler.getTagValue( dnd, \"DragType\" ) );\n      data =\n        new String( Base64.decodeBase64( XMLHandler.getTagValue( dnd, \"Data\" ).getBytes() ), Const.XML_ENCODING );\n    } catch ( Exception e ) {\n      throw new KettleXMLException( \"Unexpected error parsing Drag & Drop XML fragment: \" + xml, e );\n    }\n  }\n\n}\n","sourceCodeStart":150,"sourceCodeEnd":173,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/ui/src/main/java/org/pentaho/di/core/dnd/DragAndDropContainer.java#L150-L173","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the raw XML in the message — confirm it contains <DragAndDrop> with ID, DragType and Data tags.","Regenerate the drag payload by re-dragging from the source tree instead of reusing stored/stale XML.","If triggered programmatically, build the XML via DragAndDropContainer.getXML() rather than string concatenation.","Upgrade both PDI sides to matching versions if this occurs during cross-version drag-and-drop."],"exampleFix":"// before: hand-built fragment missing Data\nString xml = \"<DragAndDrop><ID>1</ID><DragType>TRANS</DragType></DragAndDrop>\";\n// after: produce the payload via the container itself\nString xml = new DragAndDropTree(...).getXML(); // includes Base64-encoded Data","handlingStrategy":"try-catch","validationCode":"// validate the fragment shape before constructing the container\nboolean valid = xml != null && xml.contains(\"<ID>\") && xml.contains(\"<DragType>\") && xml.contains(\"<Data>\");\nif (!valid) throw new IllegalArgumentException(\"Not a DragAndDrop XML fragment\");","typeGuard":null,"tryCatchPattern":"try { DragAndDropContainer c = new DragAndDropContainer(xml); }\ncatch (KettleXMLException e) {\n  log.error(\"Bad drag&drop payload: \" + e.getMessage());\n  // discard the stale clipboard fragment and ask the user to re-drag\n}","preventionTips":["Generate DnD XML only via getXML(), never by string concatenation.","Don't persist and replay drag payloads across PDI versions.","Log the full fragment (already in the message) when reporting this bug."],"tags":["xml-parse","drag-and-drop","ui"],"backgroundTag":"json-parse-error","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}