{"record":{"id":"f01572d0511b1efa","repo":"quarkusio/quarkus","slug":"invalid-identifier-found-id","errorCode":null,"errorMessage":"Invalid identifier found: [id]","messagePattern":"Invalid identifier found: \\[id\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/qute/core/src/main/java/io/quarkus/qute/EngineImpl.java","lineNumber":125,"sourceCode":"\n    @Override\n    public String mapResult(Object result, Expression expression) {\n        String val = null;\n        for (ResultMapper mapper : resultMappers) {\n            if (mapper.appliesTo(expression.getOrigin(), result)) {\n                val = mapper.map(result, expression);\n                break;\n            }\n        }\n        if (val == null) {\n            val = result.toString();\n        }\n        return val;\n    }\n\n    public Template putTemplate(String id, Template template) {\n        if (!Identifiers.isValid(id)) {\n            throw new IllegalArgumentException(\"Invalid identifier found: [\" + id + \"]\");\n        }\n        return templates.put(id, template);\n    }\n\n    public Template getTemplate(String id) {\n        return templates.computeIfAbsent(id, this::load);\n    }\n\n    @Override\n    public boolean isTemplateLoaded(String id) {\n        return templates.containsKey(id);\n    }\n\n    @Override\n    public void clearTemplates() {\n        templates.clear();\n    }\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/qute/core/src/main/java/io/quarkus/qute/EngineImpl.java#L107-L143","documentation":"EngineImpl.putTemplate(String id, Template) requires the template id to be a valid identifier (Identifiers.isValid). Registering a template under an id containing invalid characters throws this IllegalArgumentException.","triggerScenarios":"Calling putTemplate with an id such as \"foo/bar\", \"my template\", or one starting with a digit / containing characters outside the allowed identifier set.","commonSituations":"Programmatically registering templates keyed by file paths or names with slashes/spaces instead of sanitized template ids; dynamic template registration where ids come from user input.","solutions":["Sanitize the id before registration: strip path separators/spaces and ensure it matches valid identifier rules","Derive the id from the template path the way the default loader does (e.g. 'items/detail' paths are fine only if Identifiers accepts them — otherwise normalize)","Validate with Identifiers.isValid(id) before calling putTemplate"],"exampleFix":"// before\nengine.putTemplate(\"reports/2024/q1.html\", template); // invalid id\n// after\nengine.putTemplate(\"reports_2024_q1\", template);","handlingStrategy":"validation","validationCode":"if (!io.quarkus.qute.Identifiers.isValid(id)) {\n    throw new IllegalArgumentException(\"Template id not valid: \" + id);\n}\nengine.putTemplate(id, template);","typeGuard":"boolean isValidTemplateId(String id) { return io.quarkus.qute.Identifiers.isValid(id); }","tryCatchPattern":"try {\n    engine.putTemplate(id, template);\n} catch (IllegalArgumentException e) {\n    id = id.replaceAll(\"[^A-Za-z0-9_$]\", \"_\");\n    engine.putTemplate(id, template);\n}","preventionTips":["Sanitize ids derived from file paths or user input","Normalize separators before registration","Unit-test dynamic template registration with odd ids","Prefer explicit ids over derived ones"],"tags":["qute","templates","validation","illegal-argument"],"backgroundTag":"invalid-identifier","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"}