{"record":{"id":"6fc48f95a4dc4674","repo":"apache/hadoop","slug":"can-t-understand-delegationtokenidentifier-kind-k","errorCode":null,"errorMessage":"can't understand DelegationTokenIdentifier KIND {kind}","messagePattern":"can't understand DelegationTokenIdentifier KIND (.+?)","errorType":"exception","errorClass":"org.apache.hadoop.hdfs.util.XMLUtils.InvalidXmlException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java","lineNumber":5459,"sourceCode":"    XMLUtils.addSaxString(contentHandler, \"RENEWER\",\n        token.getRenewer().toString());\n    XMLUtils.addSaxString(contentHandler, \"REALUSER\",\n        token.getRealUser().toString());\n    XMLUtils.addSaxString(contentHandler, \"ISSUE_DATE\",\n        Long.toString(token.getIssueDate()));\n    XMLUtils.addSaxString(contentHandler, \"MAX_DATE\",\n        Long.toString(token.getMaxDate()));\n    XMLUtils.addSaxString(contentHandler, \"MASTER_KEY_ID\",\n        Integer.toString(token.getMasterKeyId()));\n    contentHandler.endElement(\"\", \"\", \"DELEGATION_TOKEN_IDENTIFIER\");\n  }\n\n  public static DelegationTokenIdentifier delegationTokenFromXml(Stanza st)\n      throws InvalidXmlException {\n    String kind = st.getValue(\"KIND\");\n    if (!kind.equals(DelegationTokenIdentifier.\n        HDFS_DELEGATION_KIND.toString())) {\n      throw new InvalidXmlException(\"can't understand \" +\n        \"DelegationTokenIdentifier KIND \" + kind);\n    }\n    int seqNum = Integer.parseInt(st.getValue(\"SEQUENCE_NUMBER\"));\n    String owner = st.getValue(\"OWNER\");\n    String renewer = st.getValue(\"RENEWER\");\n    String realuser = st.getValue(\"REALUSER\");\n    long issueDate = Long.parseLong(st.getValue(\"ISSUE_DATE\"));\n    long maxDate = Long.parseLong(st.getValue(\"MAX_DATE\"));\n    int masterKeyId = Integer.parseInt(st.getValue(\"MASTER_KEY_ID\"));\n    DelegationTokenIdentifier token =\n        new DelegationTokenIdentifier(new Text(owner),\n            new Text(renewer), new Text(realuser));\n    token.setSequenceNumber(seqNum);\n    token.setIssueDate(issueDate);\n    token.setMaxDate(maxDate);\n    token.setMasterKeyId(masterKeyId);\n    return token;\n  }","sourceCodeStart":5441,"sourceCodeEnd":5477,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java#L5441-L5477","documentation":"delegationTokenFromXml() converts an offline-edits XML DELEGATION_TOKEN_IDENTIFIER stanza back into a token. It requires the KIND element to equal DelegationTokenIdentifier.HDFS_DELEGATION_KIND ('HDFS_DELEGATION_TOKEN'); any other value means the XML describes a different token type or was altered, and an InvalidXmlException is thrown. This runs during XML-to-binary conversion in OfflineEditsViewer.","triggerScenarios":"Running 'hdfs oev' with an XML input whose KIND element is not HDFS_DELEGATION_TOKEN; round-tripping XML that was hand-edited or generated by tooling that wrote a custom token kind.","commonSituations":"Operators hand-editing offline-edits XML before converting back to binary; XML produced by a different/newer Hadoop version carrying other token kinds; feeding non-HDFS delegation token XML into the HDFS converter.","solutions":["Inspect the offending stanza: grep -n 'KIND' edits.xml and compare with HDFS_DELEGATION_TOKEN.","Regenerate the XML from the original binary edits file ('hdfs oev -i edits.bin -o fresh.xml') instead of editing it.","If the record really is an HDFS token, correct KIND to HDFS_DELEGATION_TOKEN.","Use the Hadoop release that produced the log for the XML round-trip."],"exampleFix":"<!-- before -->\n<KIND>MY_CUSTOM_KIND</KIND>\n\n<!-- after -->\n<KIND>HDFS_DELEGATION_TOKEN</KIND>","handlingStrategy":"validation","validationCode":"String kind = idStanza.getValue(\"KIND\");\nif (!DelegationTokenIdentifier.HDFS_DELEGATION_KIND.toString().equals(kind)) {\n  throw new IllegalArgumentException(\n      \"Refusing to convert non-HDFS token kind: \" + kind);\n}","typeGuard":null,"tryCatchPattern":"try {\n  DelegationTokenIdentifier id = FSEditLogOp.delegationTokenFromXml(st);\n} catch (InvalidXmlException e) {\n  // report the offending KIND value and reject the input file\n}","preventionTips":["Never hand-edit offline-edits XML; regenerate it from the binary source.","Pin the Hadoop version used for XML round-trips.","Validate KIND (and other enumerated fields) before conversion."],"tags":["hdfs","offline-edits-viewer","xml","delegation-token","java"],"backgroundTag":"xml-validation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}