apache/hadoop · error · IOException
Bad header found in token storage.
Error message
Bad header found in token storage.
What it means
Credentials.readTokenStorageStream compares the leading magic bytes of the token storage file against TOKEN_STORAGE_MAGIC; a mismatch means the file is not a Hadoop credentials/token storage file (wrong format or corrupted), so its entries cannot be read.
Solutions
- Regenerate the token storage file; a bad header indicates corruption or a file written by an incompatible version.
- Verify the file is actually a Hadoop token storage file and not an unrelated file passed by mistake.
- Restore the credentials file from a backup if available.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/Credentials.java:285 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/e83f70d429a25905.
Report an issue: GitHub.
Appendix: source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/Credentials.java:285
return credentials;
} catch(IOException ioe) {
throw new IOException("Exception reading " + filename, ioe);
} finally {
IOUtils.cleanupWithLogger(LOG, in);
}
}
/**
* Convenience method for reading a token from a DataInputStream.
*
* @param in DataInputStream.
* @throws IOException raised on errors performing I/O.
*/
public void readTokenStorageStream(DataInputStream in) throws IOException {
byte[] magic = new byte[TOKEN_STORAGE_MAGIC.length];
in.readFully(magic);
if (!Arrays.equals(magic, TOKEN_STORAGE_MAGIC)) {
throw new IOException("Bad header found in token storage.");
}
SerializedFormat format;
try {
format = SerializedFormat.valueOf(in.readByte());
} catch (IllegalArgumentException e) {
throw new IOException(e);
}
switch (format) {
case WRITABLE:
readFields(in);
break;
case PROTOBUF:
readProto(in);
break;
default:
throw new IOException("Unsupported format " + format);
}
}View on GitHub (pinned to 2add963021)