{"record":{"id":"b09bbce869b88527","repo":"quarkusio/quarkus","slug":"value-is-not-a-valid-namespace-the-valu","errorCode":null,"errorMessage":"[\" + value + \"] is not a valid namespace. The value can only consist of alphanumeric characters and underscores.","messagePattern":"\\[\" \\+ value \\+ \"\\] is not a valid namespace\\. The value can only consist of alphanumeric characters and underscores\\.","errorType":"exception","errorClass":"TemplateException","httpStatus":null,"severity":"error","filePath":"independent-projects/qute/core/src/main/java/io/quarkus/qute/Namespaces.java","lineNumber":26,"sourceCode":"\n    static final Pattern NAMESPACE_PATTERN = Pattern.compile(\"[a-zA-Z0-9_]+\");\n\n    private Namespaces() {\n    }\n\n    public static boolean isValidNamespace(String value) {\n        return NAMESPACE_PATTERN.matcher(value).matches();\n    }\n\n    public static boolean isDataNamespace(String value) {\n        return DATA_NAMESPACE.equals(value);\n    }\n\n    public static String requireValid(String value) {\n        if (isValidNamespace(value)) {\n            return value;\n        }\n        throw new TemplateException(\"[\" + value\n                + \"] is not a valid namespace. The value can only consist of alphanumeric characters and underscores.\");\n    }\n\n}\n","sourceCodeStart":8,"sourceCodeEnd":31,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/qute/core/src/main/java/io/quarkus/qute/Namespaces.java#L8-L31","documentation":"Qute namespaces (the prefix before ':' in expressions like {config:property}) must contain only alphanumeric characters and underscores. Namespaces.requireValid(String) validates user-supplied namespace values (e.g. when registering a namespace resolver) and throws TemplateException for anything else. This is a fail-fast input validation so invalid namespaces are rejected at registration time rather than producing unmatchable expressions.","triggerScenarios":"Calling EngineBuilder.addNamespace(...) or Namespaces.requireValid with a value containing hyphens, dots, spaces, or starting with a digit, e.g. addNamespace(\"my-ns\") or addNamespace(\"\").","commonSituations":"Using a dotted or hyphenated namespace name by habit (like a package or config prefix); copying a namespace containing whitespace; empty string from an externalized config value.","solutions":["Use only [a-zA-Z0-9_]+ characters for the namespace, e.g. addNamespace(\"config\") instead of \"my-config\"","Sanitize the value before registration: strip/replace invalid characters with underscores","If null/blank may occur, check isValidNamespace(value) first and fail fast with a clearer application-level error","Register multiple aliases if you need several names, each individually valid"],"exampleFix":"// before\nengineBuilder.addNamespace(\"my-namespace\"); // hyphen -> TemplateException\n// after\nengineBuilder.addNamespace(\"my_namespace\");","handlingStrategy":"validation","validationCode":"String ns = candidate == null ? \"\" : candidate;\nif (!ns.matches(\"[a-zA-Z0-9_]+\")) {\n    throw new IllegalArgumentException(\"Invalid namespace: \" + ns);\n}\nengineBuilder.addNamespace(ns);","typeGuard":"boolean isValidNamespace(String v) {\n    return v != null && v.matches(\"[a-zA-Z0-9_]+\");\n}","tryCatchPattern":"try {\n    engineBuilder.addNamespace(userNamespace).build();\n} catch (TemplateException e) {\n    if (e.getMessage().contains(\"is not a valid namespace\")) {\n        throw new IllegalArgumentException(\"Namespace must be alphanumeric/underscore: \" + userNamespace, e);\n    }\n    throw e;\n}","preventionTips":["Use only [a-zA-Z0-9_] characters for namespaces","Sanitize externalized/config-provided namespace values","Check Namespaces.isValidNamespace before registration"],"tags":["qute","namespace","validation"],"backgroundTag":"invalid-namespace","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}