elastic/elasticsearch · error · IllegalArgumentException
Cannot set Elasticsearch Distribution type to ${type}. Type
Error message
Cannot set Elasticsearch Distribution type to ${type}. Type unknown. What it means
ElasticsearchDistribution.setType(String) only recognises the names of ARCHIVE and INTEG_TEST_ZIP because, per its javadoc, only public distribution types are supported here. Any other string (docker, rpm, deb, or a typo) is rejected. The typed overload setType(ElasticsearchDistributionType) must be used for the other types.
Source
Thrown at build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java:134
public ElasticsearchDistributionType getType() {
return type.get();
}
public void setType(ElasticsearchDistributionType type) {
this.type.set(type);
}
/**
* For simplicity only public distribution types are supported here
* */
public void setType(String type) {
if (type.equals(ElasticsearchDistributionTypes.ARCHIVE.getName())) {
this.type.set(ElasticsearchDistributionTypes.ARCHIVE);
} else if (type.equals(ElasticsearchDistributionTypes.INTEG_TEST_ZIP.getName())) {
this.type.set(ElasticsearchDistributionTypes.INTEG_TEST_ZIP);
} else {
throw new IllegalArgumentException("Cannot set Elasticsearch Distribution type to " + type + ". Type unknown.");
}
}
public boolean getBundledJdk() {
return bundledJdk.getOrElse(true);
}
public boolean isDocker() {
return this.type.get().isDocker();
}
public void setBundledJdk(Boolean bundledJdk) {
this.bundledJdk.set(bundledJdk);
}
public boolean getFailIfUnavailable() {
return this.failIfUnavailable.get();
}View on GitHub (pinned to db6a809a66)
Solutions
- For docker/rpm/deb use the enum overload: distribution.setType(ElasticsearchDistributionTypes.DOCKER).
- For archive/integ_test_zip ensure the string exactly matches ElasticsearchDistributionTypes.<TYPE>.getName().
- Trim and verify the spelling against the enum constant.
Example fix
// before
distribution.setType('docker')
// after
import org.elasticsearch.gradle.distribution.ElasticsearchDistributionTypes
distribution.setType(ElasticsearchDistributionTypes.DOCKER) Defensive patterns
Strategy: validation
Validate before calling
static ElasticsearchDistributionType resolveType(String name) {
for (ElasticsearchDistributionType t : ElasticsearchDistributionTypes.values()) {
if (t.getName().equals(name)) return t;
}
throw new IllegalArgumentException("Unknown distribution type name: " + name);
}
distribution.setType(resolveType(typeName)); Type guard
static boolean isKnownTypeName(String name) {
return Arrays.stream(ElasticsearchDistributionTypes.values())
.map(ElasticsearchDistributionType::getName).anyMatch(name::equals);
} Prevention
- Prefer the enum overload setType(ElasticsearchDistributionType) over the string overload.
- Validate the string against ElasticsearchDistributionTypes values before passing.
- Trim whitespace from generated type names.
When it happens
Trigger: A build script calls distribution.setType("docker") or setType("rpm") instead of the typed enum overload, or passes a misspelled name like "archive " (trailing space) or "integ-zip".
Common situations: A contributor assumes the string overload covers all distribution types; a copy-paste from older API docs; trailing whitespace from a generated script.
Related errors
- platform cannot be set on elasticsearch distribution [${name
- bundledJdk cannot be set on elasticsearch distribution [${na
- failIfUnavailable cannot be 'false' on elasticsearch distrib
- License category name must be exactly 5 characters, got ${ca
- distribution type [${typeName}] for elasticsearch distributi
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/1de12bd7e2ea84fd.
Report an issue: GitHub.