{"record":{"id":"3015ea69fd7d7787","repo":"karatelabs/karate","slug":"failed-to-write-html-report","errorCode":null,"errorMessage":"Failed to write HTML report: {}","messagePattern":"Failed to write HTML report: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/output/HtmlReportWriter.java","lineNumber":147,"sourceCode":"     * This is the backward-compatible entry point for direct invocation.\n     *\n     * @param result    the suite result to render\n     * @param outputDir the directory to write reports\n     * @param env       the karate environment (may be null)\n     */\n    public static void write(SuiteResult result, Path outputDir, String env) {\n        try {\n            // Build data structures from SuiteResult\n            Map<String, Object> suiteData = buildSuiteData(result, env);\n            List<Map<String, Object>> features = buildFeaturesList(result);\n\n            // Generate reports\n            writeReports(suiteData, features, outputDir);\n\n            logger.debug(\"HTML report written to: {}\", outputDir.resolve(\"karate-summary.html\"));\n\n        } catch (Exception e) {\n            logger.warn(\"Failed to write HTML report: {}\", e.getMessage());\n            if (logger.isDebugEnabled()) {\n                logger.debug(\"HTML report error details\", e);\n            }\n        }\n    }\n\n    /**\n     * Write a single feature HTML report.\n     * Used by {@link HtmlReportListener} for async feature HTML generation.\n     *\n     * @param result    the feature result to render\n     * @param outputDir the root output directory (features/ subdirectory will be used)\n     */\n    public static void writeFeatureHtml(FeatureResult result, Path outputDir) throws IOException {\n        writeFeatureHtml(result, outputDir, java.util.Collections.emptyMap());\n    }\n\n    public static void writeFeatureHtml(FeatureResult result, Path outputDir,","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/output/HtmlReportWriter.java#L129-L165","documentation":"HtmlReportWriter.write() builds the whole HTML report (summary and per-feature pages) inside a single try block; any exception during data assembly, template rendering, or file writing is swallowed and logged as this warning. The test run is unaffected, but no (or a partial) HTML report is produced.","triggerScenarios":"Any exception from writeReports(suiteData, features, outputDir) — missing/broken template resources, IOException writing karate-summary.html or feature pages, serialization failure on suite data, or an output directory that cannot be created.","commonSituations":"Read-only or non-existent output directory; disk full; custom report templates/resources removed by build filtering; NPE from unexpected FeatureResult data in custom pipelines; concurrent deletion of outputDir by a clean step.","solutions":["Enable DEBUG logging for the writer to get the full stack trace ('HTML report error details') and fix the underlying exception","Ensure the output directory path is valid and writable before the suite starts","Check disk space and antivirus/file-lock interference on CI agents","If templates were customized, verify the classpath resources still exist under the report RESOURCE_ROOT"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!Files.isDirectory(outputDir) && !outputDir.toFile().mkdirs()) {\n    throw new IllegalStateException(\"cannot create report dir: \" + outputDir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    writeReports(suiteData, features, outputDir);\n} catch (Exception e) {\n    logger.warn(\"Failed to write HTML report\", e); // always log full stack when debugging\n}","preventionTips":["Enable DEBUG logging for io.karatelabs.output to capture stack traces","Verify outputDir writability before the suite starts","Keep report template resources intact when customizing builds"],"tags":["reporting","filesystem","html-report"],"backgroundTag":"file-write-failed","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}