quarkusio/quarkus · error · TemplateException

Enum constant message not found in bundle [%s] for key: %s

Error message

Enum constant message not found in bundle [%s] for key: %s

What it means

During message bundle processing, Qute generates a switch/select template over enum constants for localized enum messages. For each constant it looks up a message template by a derived key (e.g. myEnum_CONSTANT); if no template with that key exists in the bundle, the deployment fails with this TemplateException.

Source

Thrown at extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/MessageBundleProcessor.java:1113

                    if (messageTemplate == null && method.parametersCount() == 1) {
                        Type paramType = method.parameterType(0);
                        if (paramType.kind() == org.jboss.jandex.Type.Kind.CLASS) {
                            ClassInfo maybeEnum = index.getClassByName(paramType.name());
                            if (maybeEnum != null && maybeEnum.isEnum()) {
                                StringBuilder generatedMessageTemplate = new StringBuilder("{#when ")
                                        .append(getParameterName(method, 0))
                                        .append("}");
                                Set<String> enumConstants = maybeEnum.fields().stream().filter(FieldInfo::isEnumConstant)
                                        .map(FieldInfo::name).collect(Collectors.toSet());
                                String separator = enumConstantSeparator(enumConstants);
                                for (String enumConstant : enumConstants) {
                                    // myEnum_CONSTANT
                                    // myEnum_$CONSTANT_1
                                    // myEnum_$CONSTANT$NEXT
                                    String enumConstantKey = toEnumConstantKey(method.name(), separator, enumConstant);
                                    String enumConstantTemplate = messageTemplates.get(enumConstantKey);
                                    if (enumConstantTemplate == null) {
                                        throw new TemplateException(
                                                String.format("Enum constant message not found in bundle [%s] for key: %s",
                                                        bundleName + (locale != null ? "_" + locale : ""), enumConstantKey));
                                    }
                                    generatedMessageTemplate.append("{#is ")
                                            .append(enumConstant)
                                            .append("}{")
                                            .append(bundle.getName())
                                            .append(":")
                                            .append(enumConstantKey)
                                            .append("}");
                                    // For each constant we generate a method:
                                    // myEnum_CONSTANT(MyEnum val)
                                    // myEnum_$CONSTANT_1(MyEnum val)
                                    // myEnum_$CONSTANT$NEXT(MyEnum val)
                                    generateEnumConstantMessageMethod(cc, bundleName, locale, bundleInterface,
                                            defaultBundleInterface, enumConstantKey, keyMap, enumConstantTemplate,
                                            messageTemplateMethods);
                                }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add a message template for the missing enum constant key shown in the error message to the bundle interface or properties file
  2. Regenerate the key mentally: bundleMethodName + separator (usually '_') + ENUM_CONSTANT, and make sure it matches exactly
  3. Remove the enum constant from the enum or stop localizing that enum if the message is not needed

Example fix

// before (enum Color { RED, GREEN }, missing GREEN)
@Message("color = {myEnum}")
String colorName(Color myEnum);
// after
@Message("red")
String colorName_red(); // keys: colorName_red, colorName_green per constant convention
Defensive patterns

Strategy: validation

Validate before calling

// Build-time failure; validate constants before deploy
for (Color c : Color.values()) {
    String key = "colorName_" + c.name();
    if (!bundleKeys.contains(key)) throw new IllegalStateException("Missing bundle key: " + key);
}

Prevention

When it happens

Trigger: A @MessageBundle interface method takes an enum parameter and is used for enum localization, but a @Message/bundle template does not exist for one or more enum constants of that enum (key derived from bundle method name + separator + constant name).

Common situations: Adding a new enum constant to an existing localized enum without adding the corresponding bundle message; typos in the message key; renaming a constant without updating the bundle.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/c5f42724401b75a2. Report an issue: GitHub.