apache/hadoop · error · org.apache.hadoop.hdfs.util.XMLUtils.InvalidXmlException

can't understand DelegationTokenIdentifier KIND {kind}

Error message

can't understand DelegationTokenIdentifier KIND {kind}

What it means

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.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java:5459

    XMLUtils.addSaxString(contentHandler, "RENEWER",
        token.getRenewer().toString());
    XMLUtils.addSaxString(contentHandler, "REALUSER",
        token.getRealUser().toString());
    XMLUtils.addSaxString(contentHandler, "ISSUE_DATE",
        Long.toString(token.getIssueDate()));
    XMLUtils.addSaxString(contentHandler, "MAX_DATE",
        Long.toString(token.getMaxDate()));
    XMLUtils.addSaxString(contentHandler, "MASTER_KEY_ID",
        Integer.toString(token.getMasterKeyId()));
    contentHandler.endElement("", "", "DELEGATION_TOKEN_IDENTIFIER");
  }

  public static DelegationTokenIdentifier delegationTokenFromXml(Stanza st)
      throws InvalidXmlException {
    String kind = st.getValue("KIND");
    if (!kind.equals(DelegationTokenIdentifier.
        HDFS_DELEGATION_KIND.toString())) {
      throw new InvalidXmlException("can't understand " +
        "DelegationTokenIdentifier KIND " + kind);
    }
    int seqNum = Integer.parseInt(st.getValue("SEQUENCE_NUMBER"));
    String owner = st.getValue("OWNER");
    String renewer = st.getValue("RENEWER");
    String realuser = st.getValue("REALUSER");
    long issueDate = Long.parseLong(st.getValue("ISSUE_DATE"));
    long maxDate = Long.parseLong(st.getValue("MAX_DATE"));
    int masterKeyId = Integer.parseInt(st.getValue("MASTER_KEY_ID"));
    DelegationTokenIdentifier token =
        new DelegationTokenIdentifier(new Text(owner),
            new Text(renewer), new Text(realuser));
    token.setSequenceNumber(seqNum);
    token.setIssueDate(issueDate);
    token.setMaxDate(maxDate);
    token.setMasterKeyId(masterKeyId);
    return token;
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Inspect the offending stanza: grep -n 'KIND' edits.xml and compare with HDFS_DELEGATION_TOKEN.
  2. Regenerate the XML from the original binary edits file ('hdfs oev -i edits.bin -o fresh.xml') instead of editing it.
  3. If the record really is an HDFS token, correct KIND to HDFS_DELEGATION_TOKEN.
  4. Use the Hadoop release that produced the log for the XML round-trip.

Example fix

<!-- before -->
<KIND>MY_CUSTOM_KIND</KIND>

<!-- after -->
<KIND>HDFS_DELEGATION_TOKEN</KIND>
Defensive patterns

Strategy: validation

Validate before calling

String kind = idStanza.getValue("KIND");
if (!DelegationTokenIdentifier.HDFS_DELEGATION_KIND.toString().equals(kind)) {
  throw new IllegalArgumentException(
      "Refusing to convert non-HDFS token kind: " + kind);
}

Try / catch

try {
  DelegationTokenIdentifier id = FSEditLogOp.delegationTokenFromXml(st);
} catch (InvalidXmlException e) {
  // report the offending KIND value and reject the input file
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/6fc48f95a4dc4674. Report an issue: GitHub.