{"record":{"id":"c705fb5e986ad822","repo":"pentaho/pentaho-kettle","slug":"unknown-xml-event-event","errorCode":null,"errorMessage":"Unknown XML event: [event]","messagePattern":"Unknown XML event: \\[event\\]","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/xml/XMLFormatter.java","lineNumber":143,"sourceCode":"            cdata.append( rd.getText() );\n            wasSomething = true;\n            break;\n          case XMLStreamConstants.COMMENT:\n            if ( !whitespacesOnly( str ) ) {\n              wr.writeCharacters( str.toString() );\n            } else if ( wasSomething ) {\n              wr.writeCharacters( \"\\n\" + prefix );\n            }\n            str.setLength( 0 );\n            wr.writeComment( rd.getText() );\n            wasSomething = true;\n            break;\n          case XMLStreamConstants.END_DOCUMENT:\n            wr.writeCharacters( \"\\n\" );\n            wr.writeEndDocument();\n            break;\n          default:\n            throw new RuntimeException( \"Unknown XML event: \" + event );\n        }\n      }\n\n      wr.flush();\n\n      return result.toString();\n    } catch ( XMLStreamException ex ) {\n      throw new RuntimeException( ex );\n    } finally {\n      try {\n        if ( wr != null ) {\n          wr.close();\n        }\n      } catch ( Exception ex ) {\n      }\n      try {\n        if ( rd != null ) {\n          rd.close();","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/xml/XMLFormatter.java#L125-L161","documentation":"Identical RuntimeException from XMLFormatter.format()'s default switch case; the recorded message contains the event value already substituted ('[event]'), meaning the formatter hit an XML stream event type it does not know how to render.","triggerScenarios":"Same as 576: the StaX cursor returns an event constant not covered by the implemented cases (e.g. COMMENT=5, DTD=11, PROCESSING_INSTRUCTION=3) while formatting.","commonSituations":"Same as 576: documents with DOCTYPE, comments, processing instructions, or entity references; differences between StaX implementations (Woodstox vs JDK default).","solutions":["Identify the event constant from the message value and handle it explicitly in the switch","Skip benign events (comment, DTD, processing instruction) instead of throwing","Pre-process the XML to remove non-content nodes","Configure the XMLInputFactory to coalesce text and expand entity references","Catch RuntimeException around format() and fall back to returning the input unformatted"],"exampleFix":"// before\nString out = XMLFormatter.format( xml );\n// after\nString out;\ntry {\n  out = XMLFormatter.format( xml );\n} catch ( RuntimeException e ) {\n  log.logMinimal( \"XML formatting failed, using original: \" + e.getMessage() );\n  out = xml;\n}","handlingStrategy":"try-catch","validationCode":"// Same pre-check as 576\nboolean risky = xml.contains( \"<!DOCTYPE\" ) || xml.contains( \"<?\" ) || xml.contains( \"<!--\" );","typeGuard":null,"tryCatchPattern":"try {\n  result = XMLFormatter.format( xml );\n} catch ( RuntimeException e ) {\n  if ( e.getMessage().startsWith( \"Unknown XML event:\" ) ) {\n    log.logMinimal( \"Skipping formatting: \" + e.getMessage() );\n    result = xml;\n  } else {\n    throw e;\n  }\n}","preventionTips":["Remove comments/PIs/DOCTYPE from generated XML before formatting","Test formatting against documents produced by all upstream emitters","Handle additional event constants in the switch defensively","Log the event number to map it to XMLStreamConstants when it occurs"],"tags":["xml","parsing","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}