{"record":{"id":"e83f70d429a25905","repo":"apache/hadoop","slug":"bad-header-found-in-token-storage","errorCode":null,"errorMessage":"Bad header found in token storage.","messagePattern":"Bad header found in token storage\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/Credentials.java","lineNumber":285,"sourceCode":"      return credentials;\n    } catch(IOException ioe) {\n      throw new IOException(\"Exception reading \" + filename, ioe);\n    } finally {\n      IOUtils.cleanupWithLogger(LOG, in);\n    }\n  }\n\n  /**\n   * Convenience method for reading a token from a DataInputStream.\n   *\n   * @param in DataInputStream.\n   * @throws IOException raised on errors performing I/O.\n   */\n  public void readTokenStorageStream(DataInputStream in) throws IOException {\n    byte[] magic = new byte[TOKEN_STORAGE_MAGIC.length];\n    in.readFully(magic);\n    if (!Arrays.equals(magic, TOKEN_STORAGE_MAGIC)) {\n      throw new IOException(\"Bad header found in token storage.\");\n    }\n    SerializedFormat format;\n    try {\n      format = SerializedFormat.valueOf(in.readByte());\n    } catch (IllegalArgumentException e) {\n      throw new IOException(e);\n    }\n    switch (format) {\n    case WRITABLE:\n      readFields(in);\n      break;\n    case PROTOBUF:\n      readProto(in);\n      break;\n    default:\n      throw new IOException(\"Unsupported format \" + format);\n    }\n  }","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/Credentials.java#L267-L303","documentation":"Error \"Bad header found in token storage.\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/Credentials.java:285 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}