{"record":{"id":"74a5451a60616bd1","repo":"quarkusio/quarkus","slug":"s-is-not-an-enum-constant-of-s-s","errorCode":null,"errorMessage":"%s is not an enum constant of %s: %s","messagePattern":"(.+?) is not an enum constant of (.+?): (.+?)","errorType":"exception","errorClass":"MessageBundleException","httpStatus":null,"severity":"error","filePath":"extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/MessageBundleProcessor.java","lineNumber":946,"sourceCode":"\n    private boolean isEnumConstantMessageKey(String separator, String key, IndexView index, ClassInfo bundleInterface) {\n        int lastIdx = key.lastIndexOf(separator);\n        if (lastIdx != -1 && lastIdx != key.length()) {\n            String methodName = key.substring(0, lastIdx);\n            String constant = key.substring(lastIdx + separator.length(), key.length());\n            MethodInfo method = messageBundleMethod(bundleInterface, methodName);\n            if (method != null && method.parametersCount() == 1) {\n                Type paramType = method.parameterType(0);\n                if (paramType.kind() == org.jboss.jandex.Type.Kind.CLASS) {\n                    ClassInfo maybeEnum = index.getClassByName(paramType.name());\n                    if (maybeEnum != null && maybeEnum.isEnum()) {\n                        if (maybeEnum.fields().stream()\n                                .filter(FieldInfo::isEnumConstant)\n                                .map(FieldInfo::name)\n                                .anyMatch(constant::equals)) {\n                            return true;\n                        }\n                        throw new MessageBundleException(\n                                String.format(\"%s is not an enum constant of %s: %s\", constant, maybeEnum, key));\n                    }\n                }\n            }\n        }\n        return false;\n    }\n\n    private void constructLine(StringBuilder builder, Iterator<String> it) {\n        if (it.hasNext()) {\n            String nextLine = adaptLine(it.next());\n            if (nextLine.endsWith(\"\\\\\")) {\n                builder.append(nextLine.substring(0, nextLine.length() - 1));\n                constructLine(builder, it);\n            } else {\n                builder.append(nextLine);\n            }\n        }","sourceCodeStart":928,"sourceCodeEnd":964,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/MessageBundleProcessor.java#L928-L964","documentation":"Qute supports per-enum-constant messages with keys of the form EnumName_CONSTANT or _$ prefix conventions. When isEnumConstantMessageKey resolves a key to an enum type, it verifies the constant actually exists as an enum constant field on that enum; if not, the build fails reporting the constant, the enum, and the key. This guards against typos in enum-constant message keys.","triggerScenarios":"A properties key like `Color_RED` where Color enum has no RED constant (e.g. it is named `REDISH` or was renamed); key references a constant removed from the enum.","commonSituations":"Renaming or deleting enum constants without updating per-constant message keys in bundle properties files; misspelling the constant part of the key; copying keys between projects with slightly different enums.","solutions":["Fix the key in the properties file to use an existing enum constant, e.g. `Color_GREEN` instead of `Color_RED`.","Or re-add the missing constant to the enum if it should exist.","Regenerate/verify the list of constants against the enum source before re-building."],"exampleFix":"// before (messages.properties)\nColor_RED=Red color\n// enum Color { GREEN, BLUE }\n\n// after\nColor_GREEN=Green color","handlingStrategy":"validation","validationCode":"// Verify enum-constant keys reference real constants\nEnumMap-check: for key \"Color_RED\", assert\njava.util.Arrays.stream(Color.values()).anyMatch(e -> e.name().equals(\"RED\"));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate per-constant keys when enum constants are renamed/removed","Use IDE rename refactoring across properties files","Keep enum message keys adjacent to the enum source in review"],"tags":["quarkus","qute","enum","message-bundle"],"backgroundTag":"message-key-mismatch","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"}