{"record":{"id":"f101cd152a576d4c","repo":"quarkusio/quarkus","slug":"template-source-not-available","errorCode":null,"errorMessage":"Template source not available","messagePattern":"Template source not available","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"warning","filePath":"extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/devmode/QuteErrorPageSetup.java","lineNumber":207,"sourceCode":"            // src/main/resources/templates\n            Path templates = resource.resolve(\"templates\");\n            if (Files.exists(templates)) {\n                // src/main/resources/templates/items.html\n                Path template = templates.resolve(templateId.replace(\"\\\\\", \"/\"));\n                if (Files.exists(template)) {\n                    return Files.newBufferedReader(template);\n                }\n            }\n        }\n        // Source file not available - try to search the generated contents\n        Map<String, String> generatedContents = DevConsoleManager.getGlobal(GENERATED_CONTENTS);\n        if (generatedContents != null) {\n            String template = generatedContents.get(templateId);\n            if (template != null) {\n                return new BufferedReader(new StringReader(template));\n            }\n        }\n        throw new IllegalStateException(\"Template source not available\");\n    }\n\n    private Object getOrigin(Throwable t) {\n        Object origin = null;\n        try {\n            Method getOrigin = t.getClass().getClassLoader().loadClass(TEMPLATE_EXCEPTION).getMethod(\"getOrigin\");\n            origin = getOrigin.invoke(t);\n        } catch (NoSuchMethodException | SecurityException | ClassNotFoundException | IllegalAccessException\n                | IllegalArgumentException | InvocationTargetException e) {\n            LOG.warn(\"Unable to read the origin field\", e);\n        }\n        return origin;\n    }\n\n    private String getTemplateId(Object origin) {\n        String templateId = null;\n        try {\n            Method getTemplateId = origin.getClass().getClassLoader().loadClass(ORIGIN).getMethod(\"getTemplateId\");","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/devmode/QuteErrorPageSetup.java#L189-L225","documentation":"In dev mode, QuteErrorPageSetup builds problem info for template exceptions by reading the template source. getBufferedReader throws this IllegalStateException when neither the on-disk source nor the captured generated content is available for the template id involved in the error — meaning the error page cannot show the template snippet.","triggerScenarios":"A template exception occurs in dev mode and the error page tries to load the source of a template that no longer exists on disk and is not in generatedContents (e.g. template generated in memory or deleted after compilation).","commonSituations":"Hot-reload race where a template is deleted/renamed while an error page renders; errors originating from programmatically generated templates (Strings/templates built at build time); stale browser page referencing a removed template.","solutions":["Refresh/restart dev mode (press 'r' or restart quarkus:dev) so sources and generated contents are back in sync.","Restore the deleted/renamed template file referenced by the error.","If the template is generated, ensure it is registered via the generated-contents mechanism (TemplateData/generated template APIs) rather than expected on disk.","Check the actual template exception in the log — this error only obscures the source snippet, the root cause is the underlying template error."],"exampleFix":"// before: template removed from src/main/resources/templates\n// after: restore the file, e.g.\n// src/main/resources/templates/page.html","handlingStrategy":"fallback","validationCode":"if (!Files.exists(Path.of(\"src/main/resources/templates\", templatePath))) {\n    log.warn(\"Template source missing; error page snippet unavailable\");\n}","typeGuard":null,"tryCatchPattern":"try { renderProblemInfo(t); } catch (IllegalStateException e) { if (e.getMessage().equals(\"Template source not available\")) { showPlainErrorPage(t); } else throw e; }","preventionTips":["Restart dev mode after bulk template moves/deletes","Don't keep stale browser tabs pointing at removed templates","Check the log for the real underlying template exception first"],"tags":["qute","dev-mode","error-page","templates"],"backgroundTag":"dev-mode-source-unavailable","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}