quarkusio/quarkus · error · MessageBundleException
A constant of a localized enum may not contain '_$': {consta
Error message
A constant of a localized enum may not contain '_$': {constant} What it means
Qute uses '_$' as a special separator when deriving enum-constant message keys, so enum constants containing the literal sequence '_$' would produce ambiguous keys. enumConstantSeparator() throws MessageBundleException if any constant of a localized enum contains '_$'.
Source
Thrown at extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/MessageBundleProcessor.java:1217
}
}
// Render the template
// At this point it's already validated that the method returns String
bc.return_(bc.invokeInterface(
io.quarkus.qute.deployment.Descriptors.TEMPLATE_INSTANCE_RENDER, templateInstance));
}
});
});
}
implementResolve(defaultBundleImpl, cc, keyMap, resolveMethodPrefix, generatedClassName);
});
return generatedClassName;
}
private String enumConstantSeparator(Set<String> enumConstants) {
for (String constant : enumConstants) {
if (constant.contains("_$")) {
throw new MessageBundleException("A constant of a localized enum may not contain '_$': " + constant);
}
if (constant.contains("$") || constant.contains("_")) {
// If any of the constants contains "_" or "$" then "_$" is used
return "_$";
}
}
return "_";
}
private String toEnumConstantKey(String methodName, String separator, String enumConstant) {
return methodName + separator + enumConstant;
}
private void generateEnumConstantMessageMethod(ClassCreator bundleCreator, String bundleName, String locale,
ClassInfo bundleInterface, ClassInfo defaultBundleInterface, String enumConstantKey,
Map<String, MessageMethod> keyMap, String messageTemplate,
BuildProducer<MessageBundleMethodBuildItem> messageTemplateMethods) {
String templateId = null;View on GitHub (pinned to e1c734241f)
Solutions
- Rename the enum constant to remove the '_$' sequence
- Do not localize that enum via the message bundle mechanism
- Split the constant into a name without special characters plus separate data
Example fix
// before
enum Codes { A_$1, A_B }
// after
enum Codes { A_1, A_B }
Defensive patterns
Strategy: validation
Validate before calling
for (Field f : MyEnum.class.getEnumConstants()) {
if (((Enum<?>) f).name().contains("_$"))
throw new IllegalStateException("Enum constant contains '_$': " + ((Enum<?>) f).name());
} Prevention
- Coding-standard check banning '_$' in enum constant names
- Review generated/mapped enum names before localizing them
When it happens
Trigger: Localizing an enum (via a message bundle method taking the enum) where at least one enum constant name contains the substring "_$" and another constant contains '_' or '$' (triggering '_$' as separator).
Common situations: Machine-generated or encoded enum constant names that embed '_$'; constants like FOO_$BAR colliding with the separator scheme.
Related errors
- Enum constant message not found in bundle [%s] for key: %s
- Message bundle name [%s] declared on %s must be a valid name
- Message bundle interface name conflict - [%s] is used for bo
- Locale of [%s] conflicts with the locale [%s] of the default
- Cannot register [%s] - a localized message bundle interface
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/0e210a47880ee95c.
Report an issue: GitHub.