{"record":{"id":"3663836a7afeac79","repo":"apache/hadoop","slug":"unable-to-initialize-history-viewer","errorCode":null,"errorMessage":"Unable to initialize History Viewer","messagePattern":"Unable to initialize History Viewer","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/jobhistory/HistoryViewer.java","lineNumber":85,"sourceCode":"   * Constructs the HistoryViewer object.\n   * @param historyFile the fully qualified Path of the History File\n   * @param conf the Configuration file\n   * @param printAll toggle to print all status to only killed/failed status\n   * @param format the output format to use\n   * @throws IOException when there is a problem parsing the history file\n   */\n  public HistoryViewer(String historyFile, Configuration conf, boolean printAll,\n                       String format) throws IOException {\n    String errorMsg = \"Unable to initialize History Viewer\";\n    try {\n      Path jobFile = new Path(historyFile);\n      fs = jobFile.getFileSystem(conf);\n      String[] jobDetails =\n        jobFile.getName().split(\"_\");\n      if (jobDetails.length < 2) {\n        // NOT a valid name\n        System.err.println(\"Ignore unrecognized file: \" + jobFile.getName());\n        throw new IOException(errorMsg);\n      }\n      JobHistoryParser parser = new JobHistoryParser(fs, jobFile);\n      job = parser.parse();\n      String scheme = WebAppUtils.getHttpSchemePrefix(fs.getConf());\n      if (HUMAN_FORMAT.equalsIgnoreCase(format)) {\n        jhvp = new HumanReadableHistoryViewerPrinter(job, printAll, scheme);\n      } else if (JSON_FORMAT.equalsIgnoreCase(format)) {\n        jhvp = new JSONHistoryViewerPrinter(job, printAll, scheme);\n      } else {\n        System.err.println(\"Invalid format specified: \" + format);\n        throw new IllegalArgumentException(errorMsg);\n      }\n    } catch(IOException e) {\n      throw new IOException(errorMsg, e);\n    }\n  }\n\n  /**","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/jobhistory/HistoryViewer.java#L67-L103","documentation":"HistoryViewer requires the history file's base name to look like a job history name: it splits on '_' and requires at least 2 segments (job_<id>...). When the name has no '_' at all (jobDetails.length < 2), it prints \"Ignore unrecognized file: <name>\" to stderr and throws IOException(\"Unable to initialize History Viewer\"). The errorIndex points at the throw inside the name check (HistoryViewer.java:85).","triggerScenarios":"Constructing HistoryViewer (or running 'mapreduce job -history') with a path whose file name contains no underscore - e.g. 'summary.txt', 'jobconf', a directory-ish name, or a mistyped/garbled path.","commonSituations":"Passing the job conf/xml or a log file instead of the .jhist; shell scripts globbing the wrong directory; typos in the history path; tools that rename history files dropping the job_<submitter> pattern.","solutions":["Pass the real history file: job_<jobid>[-...].jhist from the Yarn done/intermediatedone/ history directories.","Validate the name before constructing the viewer: require a '_' in the file name.","Check stderr - the preceding 'Ignore unrecognized file' line names the offending file.","List the history directory and copy the exact .jhist name."],"exampleFix":"// before\nnew HistoryViewer(\"/user/me/Logs/jobconf.xml\", conf, true);\n\n// after\nnew HistoryViewer(\"/tmp/hadoop-yarn/staging/history/done/2026/08/22/000000/\"\n    + \"job_1690000000000_0001-1690000000000-user-word+count-1-0-user-StreamJob.jhist\",\n    conf, true);","handlingStrategy":"validation","validationCode":"String name = Path.getPathWithoutSchemeAndAuthority(historyPath).getName();\nif (name.split(\"_\").length < 2) {\n  throw new IllegalArgumentException(\"Not a job history file name (expected job_* pattern): \" + name);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass only real .jhist files whose names start with 'job_'.","In directory scans, filter file names on ^job_.* before constructing HistoryViewer.","Watch stderr - 'Ignore unrecognized file:' names the bad file before the throw."],"tags":["hadoop","mapreduce","jobhistory","filename-validation","ioexception"],"backgroundTag":"invalid-filename-format","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}