quarkusio/quarkus · error · IllegalArgumentException
Merging of KubernetesDeploymentTargetBuildItem having differ
Error message
Merging of KubernetesDeploymentTargetBuildItem having different 'name' or 'kind' fields is not allowed.
What it means
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.
Source
Thrown at extensions/kubernetes/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesDeploymentTargetBuildItem.java:108
return this.name.equals(other.getName()) && this.kind.equals(other.getKind());
}
public boolean nameAndKindMatchButNotEquals(KubernetesDeploymentTargetBuildItem other) {
return !this.equals(other) && nameAndKindMatch(other);
}
public Map.Entry<String, String> nameToKindEntry() {
return new AbstractMap.SimpleEntry<>(this.name, this.kind);
}
/**
* Create a new {@code KubernetesDeploymentTargetBuildItem} that contains the maximum of the two priorities
* and the logical 'OR' of the {@code enabled} field.
* {@code name} and {@code kind} must match, otherwise an exception is thrown
*/
private KubernetesDeploymentTargetBuildItem merge(KubernetesDeploymentTargetBuildItem other) {
if (!nameAndKindMatch(other)) {
throw new IllegalArgumentException(
"Merging of KubernetesDeploymentTargetBuildItem having different 'name' or 'kind' fields is not allowed.");
}
return new KubernetesDeploymentTargetBuildItem(this.name, this.kind, this.group, this.version,
Math.max(this.priority, other.getPriority()),
this.enabled || other.isEnabled(),
this.deployStrategy);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
KubernetesDeploymentTargetBuildItem that = (KubernetesDeploymentTargetBuildItem) o;
return priority == that.priority &&
enabled == that.enabled &&View on GitHub (pinned to e1c734241f)
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
Example fix
// before
new KubernetesDeploymentTargetBuildItem("deploy", "CronJob", ...)
// after (match existing entry)
new KubernetesDeploymentTargetBuildItem("deploy", "Deployment", ...) Defensive patterns
Strategy: validation
Validate before calling
boolean nameAndKindMatch(a, b) { return a.getName().equals(b.getName()) && a.getKind().equals(b.getKind()); } Type guard
static boolean isMergeable(KubernetesDeploymentTargetBuildItem a, KubernetesDeploymentTargetBuildItem b) {
return a != null && b != null && a.getName().equals(b.getName()) && a.getKind().equals(b.getKind());
} Try / catch
try { merged = item.merge(other); } catch (IllegalArgumentException e) { log.error("Deployment target name/kind mismatch: " + e.getMessage()); } Prevention
- 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
When it happens
Trigger: Calling merge() (indirectly via the merging build item logic in the Kubernetes deployment pipeline) with two KubernetesDeploymentTargetBuildItem instances whose name or kind differ.
Common situations: 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.
Related errors
- At least one enabled entry must be active
- A generic type is not allowed here; try creating a subclass
- Build item class must be leaf (final) types: %s
- Cannot construct empty build items
- Unknown item type: ${otherItem.getClass()}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/f7b157ae3f3b66a5.
Report an issue: GitHub.