{"record":{"id":"ac0241174ef59a42","repo":"karatelabs/karate","slug":"failed-to-copy-static-resources","errorCode":null,"errorMessage":"Failed to copy static resources: {}","messagePattern":"Failed to copy static resources: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/output/HtmlReportListener.java","lineNumber":204,"sourceCode":"            HtmlReportWriter.writeSummaryPages(featureMaps, result, outputDir, env, reportAssets, summaryCards);\n\n            // Write timeline page using canonical feature maps\n            HtmlReportWriter.writeTimelineHtml(featureMaps, result, outputDir, env, threadCount, reportAssets);\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 summary: {}\", e.getMessage());\n        }\n    }\n\n    private synchronized void ensureResourcesCopied() {\n        if (!resourcesCopied) {\n            try {\n                HtmlReportWriter.copyStaticResources(outputDir.resolve(\"res\"));\n                resourcesCopied = true;\n            } catch (Exception e) {\n                logger.warn(\"Failed to copy static resources: {}\", e.getMessage());\n            }\n        }\n    }\n\n}\n","sourceCodeStart":186,"sourceCodeEnd":210,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/output/HtmlReportListener.java#L186-L210","documentation":"HtmlReportListener.ensureResourcesCopied() copies the report's static resources (CSS/JS) into <outputDir>/res via HtmlReportWriter.copyStaticResources once per suite. If that copy fails for any reason, the listener logs a warning instead of failing the test run — reporting is best-effort by design, so tests still execute but the generated HTML report may be missing styling/scripts.","triggerScenarios":"Any exception thrown by HtmlReportWriter.copyStaticResources(Path) when onFeatureEnd or onSuiteEnd first triggers the lazy copy — e.g. the output directory cannot be created or written, classpath resources are missing, or disk is full.","commonSituations":"Output dir points to a read-only path or one owned by another user; disk full on CI; outputDir deleted or replaced mid-run; running inside a packaged/jlink or shaded jar where the static resources were excluded from the artifact.","solutions":["Verify the output directory (karate.outputDir / -Dkarate.outputDir) exists and is writable by the process user","Check free disk space on the volume holding the output directory","If running from a custom/shaded jar, confirm karate-core's report resources under the report resource root are included (check resource filtering/excludes in the build)","Inspect debug-level logs (enable io.karatelabs.output DEBUG) or temporarily re-throw to see the full stack trace"],"exampleFix":"// before: opaque message only\nlogger.warn(\"Failed to copy static resources: {}\", e.getMessage());\n// after: surface the root cause during diagnosis\nlogger.warn(\"Failed to copy static resources: {}\", e.getMessage(), e);","handlingStrategy":"fallback","validationCode":"Path res = outputDir.resolve(\"res\");\nif (!Files.isWritable(outputDir) || (Files.exists(res) && !Files.isDirectory(res))) {\n    throw new IllegalStateException(\"outputDir not writable for report resources: \" + outputDir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    HtmlReportWriter.copyStaticResources(outputDir.resolve(\"res\"));\n} catch (Exception e) {\n    logger.warn(\"report will lack static resources\", e); // keep run alive, log stack\n}","preventionTips":["Pre-create and permission-check the output directory in CI setup steps","Monitor free disk space on the report volume","Avoid shading karate-core with aggressive resource filtering"],"tags":["reporting","filesystem","html-report","classpath-resources"],"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"}