{"record":{"id":"6728837e5c91ad4b","repo":"quarkusio/quarkus","slug":"duplicate-key-s-found-on-s","errorCode":null,"errorMessage":"Duplicate key [%s] found on %s","messagePattern":"Duplicate key \\[(.+?)\\] found on (.+?)","errorType":"exception","errorClass":"MessageBundleException","httpStatus":null,"severity":"error","filePath":"extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/MessageBundleProcessor.java","lineNumber":1070,"sourceCode":"                        messageAnnotation = defaultBundleMethod.annotation(Names.MESSAGE);\n                    } else {\n                        messageAnnotation = method.annotation(Names.MESSAGE);\n                    }\n\n                    if (messageAnnotation == null) {\n                        LOG.debugf(\"@Message not declared on %s#%s - using the default key/value\", bundleInterface, method);\n                        messageAnnotation = AnnotationInstance.builder(Names.MESSAGE).value(Message.DEFAULT_VALUE)\n                                .add(\"name\", Message.DEFAULT_NAME).build();\n                    }\n\n                    String key = getKey(method, messageAnnotation, defaultKeyValue);\n                    if (key.equals(MESSAGE)) {\n                        throw new MessageBundleException(String.format(\n                                \"A message bundle interface method must not use the key 'message' which is reserved for dynamic lookup; defined for %s#%s()\",\n                                bundleInterface, method.name()));\n                    }\n                    if (keyMap.containsKey(key)) {\n                        throw new MessageBundleException(String.format(\"Duplicate key [%s] found on %s\", key, bundleInterface));\n                    }\n                    keyMap.put(key, new SimpleMessageMethod(method));\n\n                    boolean generatedTemplate = false;\n                    String messageTemplate = messageTemplates.get(method.name());\n                    if (messageTemplate == null) {\n                        messageTemplate = getMessageAnnotationValue(messageAnnotation, true);\n                    }\n\n                    if (messageTemplate == null && defaultBundleInterface != null) {\n                        // method is annotated with @Message without value() -> fallback to default locale\n                        messageTemplate = getMessageAnnotationValue((defaultBundleInterface.method(method.name(),\n                                method.parameterTypes().toArray(new Type[] {}))).annotation(Names.MESSAGE), true);\n                    }\n\n                    // We need some special handling for enum message bundle methods\n                    // A message bundle method that accepts an enum and has no message template receives a generated template:\n                    // {#when enumParamName}","sourceCodeStart":1052,"sourceCodeEnd":1088,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/MessageBundleProcessor.java#L1052-L1088","documentation":"Within one message bundle interface, each resolved message key must be unique. getKey() derives the key from the method name or @Message#key; if two methods resolve to the same key, template lookup would be ambiguous, so the build fails with the duplicate key and the bundle interface.","triggerScenarios":"Two methods mapping to the same key, e.g. `String hello();` and `@Message(key=\"hello\") String hi();`, or overloads whose keys collapse (same name, same key derivation).","commonSituations":"Copy-pasting a method and forgetting to rename it or its @Message key; adding an overload of an existing bundle method (keys don't consider parameters); merging branches that both added a method with the same key.","solutions":["Rename one of the methods or set a distinct @Message(key = \"...\") so each key is unique.","Remove the redundant duplicate method if it serves the same message.","Search the bundle interface for repeated method names and @Message key values before rebuilding."],"exampleFix":"// before\nString hello();\n@Message(key = \"hello\")\nString hi();\n\n// after\nString hello();\n@Message(key = \"hi\")\nString hi();","handlingStrategy":"validation","validationCode":"// Detect duplicate keys in a bundle interface\njava.util.Map<String,Integer> seen = new java.util.HashMap<>();\nfor (java.lang.reflect.Method m : AppMessages.class.getDeclaredMethods()) {\n    Message msg = m.getAnnotation(Message.class);\n    String key = (msg != null && !Message.DEFAULT_NAME.equals(msg.key())) ? msg.key() : m.getName();\n    if (seen.put(key, 1) != null) throw new IllegalStateException(\"Duplicate key: \" + key);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never overload bundle methods (keys ignore parameters)","Use unique @Message(key) values when method names could collide","Review bundle interfaces for duplicates before merging branches"],"tags":["quarkus","qute","message-bundle","duplicate-key"],"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"}