{"record":{"id":"95f8d1f7ed7f408f","repo":"karatelabs/karate","slug":"failed-to-load-icons-sprite","errorCode":null,"errorMessage":"Failed to load icons sprite: {}","messagePattern":"Failed to load icons sprite: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/output/HtmlReportWriter.java","lineNumber":664,"sourceCode":"                return sb.toString();\n            }\n        }\n    }\n\n    /**\n     * Load the icons sprite once per JVM and cache it. Missing sprite is logged\n     * at WARN and the splice yields the empty string — the report still renders,\n     * just without icons. See {@code _icons.svg} (Heroicons v2, MIT).\n     */\n    private static String loadIconsSprite() {\n        String cached = iconsSprite;\n        if (cached != null) {\n            return cached;\n        }\n        try {\n            cached = loadClasspathResource(RESOURCE_ROOT + \"_icons.svg\", false);\n        } catch (IOException e) {\n            logger.warn(\"Failed to load icons sprite: {}\", e.getMessage());\n            cached = \"\";\n        }\n        iconsSprite = cached;\n        return cached;\n    }\n\n    /**\n     * Copy static resources (CSS, JS, images) to the res directory.\n     * Made public for use by {@link HtmlReportListener}.\n     *\n     * @param resDir the res directory to copy resources to\n     */\n    public static void copyStaticResources(Path resDir) throws IOException {\n        for (String resourceName : STATIC_RESOURCES) {\n            String resourcePath = RESOURCE_ROOT + \"res/\" + resourceName;\n            try (InputStream is = HtmlReportWriter.class.getClassLoader().getResourceAsStream(resourcePath)) {\n                if (is != null) {\n                    Files.copy(is, resDir.resolve(resourceName), java.nio.file.StandardCopyOption.REPLACE_EXISTING);","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/output/HtmlReportWriter.java#L646-L682","documentation":"loadIconsSprite() loads the bundled _icons.svg sprite used by the HTML report shell, caching it (including a cached empty string after failure). If the classpath resource cannot be read, an IOException is logged as a warning and the report renders without the icon sprite.","triggerScenarios":"IOException from loadClasspathResource(RESOURCE_ROOT + \"_icons.svg\", false) when shell() builds the report page — the SVG resource is absent from the classpath or unreadable.","commonSituations":"Running from a shaded/minimized jar where SVG resources were stripped; custom classloader (app servers, Spring Boot nested jars) that cannot see karate-core resources; corrupted installation.","solutions":["Verify _icons.svg exists in karate-core's report resource root inside the jar on the classpath","Stop stripping *.svg or the report resource package in shade/minimize/proguard config","Test resource loading with getClass().getResourceAsStream() in the same classloading environment","If unavoidable, accept the degraded report (cached \"\" means icons are simply missing) or ship the sprite on the classpath yourself"],"exampleFix":"// build config: keep report resources in shaded jar\n<filters>\n  <filter>exclude only *.class minimization, keep **/_icons.svg</filter>\n</filters>","handlingStrategy":"fallback","validationCode":"try (InputStream in = getClass()\n        .getResourceAsStream(\"/io/karatelabs/output/_icons.svg\")) {\n    if (in == null) logger.warn(\"_icons.svg not on classpath — report icons will be missing\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    cached = loadClasspathResource(RESOURCE_ROOT + \"_icons.svg\", false);\n} catch (IOException e) {\n    logger.warn(\"Failed to load icons sprite: {}\", e.getMessage());\n    cached = \"\"; // degrade gracefully\n}","preventionTips":["Never strip SVG/resource files in shade, minimize, or proguard configs","Test report generation from the exact packaged jar, not only from IDE runs","Beware custom classloaders (Spring Boot nested jars, app servers) hiding karate-core resources"],"tags":["reporting","classpath","resources","svg"],"backgroundTag":"file-not-found","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"}