{"record":{"id":"f7b157ae3f3b66a5","repo":"quarkusio/quarkus","slug":"merging-of-kubernetesdeploymenttargetbuilditem-hav","errorCode":null,"errorMessage":"Merging of KubernetesDeploymentTargetBuildItem having different 'name' or 'kind' fields is not allowed.","messagePattern":"Merging of KubernetesDeploymentTargetBuildItem having different 'name' or 'kind' fields is not allowed\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/kubernetes/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesDeploymentTargetBuildItem.java","lineNumber":108,"sourceCode":"        return this.name.equals(other.getName()) && this.kind.equals(other.getKind());\n    }\n\n    public boolean nameAndKindMatchButNotEquals(KubernetesDeploymentTargetBuildItem other) {\n        return !this.equals(other) && nameAndKindMatch(other);\n    }\n\n    public Map.Entry<String, String> nameToKindEntry() {\n        return new AbstractMap.SimpleEntry<>(this.name, this.kind);\n    }\n\n    /**\n     * Create a new {@code KubernetesDeploymentTargetBuildItem} that contains the maximum of the two priorities\n     * and the logical 'OR' of the {@code enabled} field.\n     * {@code name} and {@code kind} must match, otherwise an exception is thrown\n     */\n    private KubernetesDeploymentTargetBuildItem merge(KubernetesDeploymentTargetBuildItem other) {\n        if (!nameAndKindMatch(other)) {\n            throw new IllegalArgumentException(\n                    \"Merging of KubernetesDeploymentTargetBuildItem having different 'name' or 'kind' fields is not allowed.\");\n        }\n\n        return new KubernetesDeploymentTargetBuildItem(this.name, this.kind, this.group, this.version,\n                Math.max(this.priority, other.getPriority()),\n                this.enabled || other.isEnabled(),\n                this.deployStrategy);\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o)\n            return true;\n        if (o == null || getClass() != o.getClass())\n            return false;\n        KubernetesDeploymentTargetBuildItem that = (KubernetesDeploymentTargetBuildItem) o;\n        return priority == that.priority &&\n                enabled == that.enabled &&","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/kubernetes/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesDeploymentTargetBuildItem.java#L90-L126","documentation":"During the Quarkus build, multiple extensions may contribute a KubernetesDeploymentTargetBuildItem describing a deployment target (Deployment, StatefulSet, Job, etc.). When two build items with the same key are merged, this private merge method requires their 'name' and 'kind' fields to match; otherwise it throws IllegalArgumentException. This guards against silently combining two distinct deployment targets (e.g. 'deploy' Deployment vs 'job' CronJob) into one.","triggerScenarios":"Calling merge() (indirectly via the merging build item logic in the Kubernetes deployment pipeline) with two KubernetesDeploymentTargetBuildItem instances whose name or kind differ.","commonSituations":"Two extensions or two quarkus.kubernetes.deployment-target values resolving to the same key slot but producing different name/kind combinations; custom extensions contributing deployment targets with colliding keys but mismatched name/kind; upgrade where a new target kind was introduced for the same key.","solutions":["Ensure each KubernetesDeploymentTargetBuildItem is created with consistent name and kind for a given key across all contributing extensions","Check which extensions contribute kubernetes deployment targets and remove or align conflicting ones","Update custom code that builds these build items so name/kind match the existing entries","If two genuinely different targets are needed, use distinct keys so no merge is attempted"],"exampleFix":"// before\nnew KubernetesDeploymentTargetBuildItem(\"deploy\", \"CronJob\", ...)\n// after (match existing entry)\nnew KubernetesDeploymentTargetBuildItem(\"deploy\", \"Deployment\", ...)","handlingStrategy":"validation","validationCode":"boolean nameAndKindMatch(a, b) { return a.getName().equals(b.getName()) && a.getKind().equals(b.getKind()); }","typeGuard":"static boolean isMergeable(KubernetesDeploymentTargetBuildItem a, KubernetesDeploymentTargetBuildItem b) {\n    return a != null && b != null && a.getName().equals(b.getName()) && a.getKind().equals(b.getKind());\n}","tryCatchPattern":"try { merged = item.merge(other); } catch (IllegalArgumentException e) { log.error(\"Deployment target name/kind mismatch: \" + e.getMessage()); }","preventionTips":["Always construct build items with matching name/kind per key","Review extensions contributing kubernetes deployment targets","Use distinct keys for genuinely different targets","Add a unit test covering your custom build item merges"],"tags":["kubernetes","build-item","merge"],"backgroundTag":"build-item-merge-conflict","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"}