{"record":{"id":"eb94edadc67162db","repo":"apache/cassandra","slug":"couldn-t-load-existing-stats-html","errorCode":null,"errorMessage":"Couldn't load existing stats html.","messagePattern":"Couldn't load existing stats html\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/StressGraph.java","lineNumber":77,"sourceCode":"    {\n        this.stressSettings = stressSetttings;\n        this.stressArguments = stressArguments;\n    }\n\n    public void generateGraph()\n    {\n        File htmlFile = new File(stressSettings.graph.file);\n        ObjectNode stats;\n        if (htmlFile.isFile())\n        {\n            try\n            {\n                String html = new String(Files.readAllBytes(Paths.get(htmlFile.toURI())), StandardCharsets.UTF_8);\n                stats = parseExistingStats(html);\n            }\n            catch (IOException e)\n            {\n                throw new RuntimeException(\"Couldn't load existing stats html.\");\n            }\n            stats = this.createJSONStats(stats);\n        }\n        else\n        {\n            stats = this.createJSONStats(null);\n        }\n\n        try\n        {\n            PrintWriter out = new PrintWriter(htmlFile);\n            String statsBlock = \"/* stats start */\\nstats = \" + JsonUtils.writeAsJsonString(stats) + \";\\n/* stats end */\\n\";\n            String html = getGraphHTML().replaceFirst(\"/\\\\* stats start \\\\*/\\n\\n/\\\\* stats end \\\\*/\\n\", statsBlock);\n            out.write(html);\n            out.close();\n        }\n        catch (IOException e)\n        {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/StressGraph.java#L59-L95","documentation":"StressGraph.generateGraph wraps any IOException from reading the previously generated HTML report into a RuntimeException with the message 'Couldn't load existing stats html.' This happens only when graphing with an existing html file whose bytes cannot be read from disk. The original IOException is swallowed, so the real cause (missing file, permissions, path issues) is not reported.","triggerScenarios":"Running cassandra-stress graph generation pointing at an existing htmlFile path that does not exist, is a directory, or is unreadable, so Files.readAllBytes in the load-existing-stats branch throws IOException.","commonSituations":"Typo in the graph file path; report file deleted or moved between runs; running in a container where the prior report volume is not mounted; read-permission problems.","solutions":["Verify the path of the existing graph HTML exists and is readable (ls / cat the file) before rerunning.","Regenerate the report from scratch by running stress graphing without the existing-html input.","Fix filesystem permissions or mount the directory containing the previous report.","Patch the catch to include the file path and cause: new RuntimeException(\"Couldn't load existing stats html: \" + htmlFile, e)."],"exampleFix":"// before\ncatch (IOException e)\n{\n    throw new RuntimeException(\"Couldn't load existing stats html.\");\n}\n// after\ncatch (IOException e)\n{\n    throw new RuntimeException(\"Couldn't load existing stats html: \" + htmlFile, e);\n}","handlingStrategy":"validation","validationCode":"java.io.File f = htmlFile; if (f == null || !f.isFile() || !f.canRead()) throw new IllegalArgumentException(\"Existing graph html not readable: \" + f);","typeGuard":null,"tryCatchPattern":"try { generateGraph(); } catch (RuntimeException e) { if (e.getMessage().contains(\"Couldn't load existing stats html\")) { System.err.println(\"Falling back to fresh graph generation\"); generateFreshGraph(); } else throw e; }","preventionTips":["Verify the existing graph html path exists and is readable before reruns.","Keep report files on stable, mounted volumes in CI/containers.","Back up previous HTML reports before regenerating."],"tags":["io","file-read","stress-graph"],"backgroundTag":"file-read-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}